We want to create (and backfill) PI tags that totalize other tags from a fixed beginning date to the present, but effectively never reset, thus increasing perpetually. I will call this an "integrator".
To do this, it is impractical to call TagTot('BaseTag', FixedTimeLongAgo, '*') because this time range will obviously become huge and the calculation way too expensive.
Instead, I've done something like this so far. The analysis that writes to the integrator calls its previous value, and adds to it the TagTot of 'BaseTag', between the previous timestamp of the integrator and the present, to get the new value:
Start := PrevEvent('Integrator','*')
End := '*'
PrevValue := PrevVal('Integrator','*')
NewAccum := TagTot('BaseTag', Start, End)
NewValue := PrevValue + NewAccum.
While this integrator appears to have sound values for time going forward, it does not backfill correctly. I think I know why, but I don't know of a way around this. The problem is that when the "PrevVal" function is called inside the backfill calculations, it does not recognize brand new values that have been created in the middle of the ongoing backfill. Each PrevVal calls looks at the same pre-backfill array of tag values, so that every PrevVal call returns the same value, which makes it impossible to iterate this moving forward.
Does anyone know of a better approach to achieve what I'm looking for, with or without an AF Analysis?
Thanks for your help,
****************** MORE INFO*************************
Tag values after a couple of backfills are shown below. After Backfill 1 the tag begins to stagnate around 49. After Backfill 2, the tag goes one step further and begins stagnating around ~54, because at each step, the "PrevVal" function is calling the tag values that existed before the entire backfill began, instead of the new tag values created in the middle of the current, new backfill.