can you please be more explicit on your question?
For now, Tagtot('myflowtag','starttime','endtime') returns the volume between the specified range time.
You just need to consider the flow uom.
If m3/h, and your time range is about 2 days then you need to multiply by 24 since one day is 24 hours.
thanks for the fast Response!
The idea is to have a calculation in AF to build a sum of the hole month and store the result in another Tag:
TagTot( 'FlowRate01', 'beginning of month', 'end of month') this calculation should run automatically at the beginning of every month and I want to store the result in another Tag.
To me the main question is:
How can I Trigger the calculation at the beginning of every month and how can I configure a dynamic scope (start time and end time) for the function?
Hello Thomas, referring to Rick post.
Just a remark, might be right might be wrong.
Assuming that the calculation will start at every first of the month
Your times are wrong. In the context of an analysis, '*' does not necessarily mean now, but rather means trigger time, which is a critical distinction when backfilling. BOM('*') when run on the first of the month returns the first of the month set at midnight. However, 'y' truly means yesterday. For the start time, I offset that yet again by 24 hours, as shown by '+24h' to denote a time span, rather than 1 day, which could also have been used. Doesn't matter because when you BOM that, it sets to the first of previous month, also at midnight. That means my time range is correct from the first of the previous month (relative to trigger) to the full end of that month (first of trigger month at midnight - no need to offset by -1 second). Your suggested changes are from the first of the last month up to the beginning of the last day of month. Coming up on May 1, your time range effectively covers only 29 days of April.
I’m afraid, I don’t see my mistake on this.
Your explanation might clarify.
Below is the shot screen from PI AF Explorer editor.
From this next 1 of May 2018 at 5AM
(‘y’) would returns 30/04/2018 12:00:00 AM
Bom(‘y’) would returns 01/04/2018 12:00:00 AM
I Think you are right in your post, my mine might be just another option.
image001.png 9.6 KB
No, Mamy, yours is wrong. A monthly summary should include ALL of April 30. You stop 1 day short. The time needs to extend through END of day April 30, which is the equivalent of May 1 at midnight, although you may jump through more hoops to make it 30/04/2018 11:59:59 PM.
And again your code only works when the trigger time is Now, but it will not work with backfilling.
2 of 2 people found this helpful
I would not recommend an event frame. I suggest using an Asset Analysis that writes to your second tag. The analysis should be periodically scheduled, and perhaps should be executed every day at some fixed time, such as 4 or 5 AM. You should avoid anytime that lies around DST transition so as to avoid any ambiguity. Typing free-form at my keyboard (not within Analytics editor), it would be something like:
IsBOM Day('*') = 1
StartTime BOM('*' - '+24h')
summary If IsBOM Then your summary here Else NoOutput()
This addresses your earlier question of How can I Trigger the calculation at the beginning of every month and how can I configure a dynamic scope (start time and end time) for the function? You really can't set a trigger for the beginning of the month given the pesky details that some months have 31 days while others have only 30, and don't get me started on February. By triggering every day, you are sure to hit the first of the month eventually. You also restrict the calculating as well as outputting the results to only the day that is indeed the first of the month. The psuedo-code I posted also dynamically scopes the previous month's time range for you.