queryTagHistory with month aggregates for reporting

My supervisory would like to generate data tables, based on queries of tag history, with time frames of ‘month’ for various values such as accumulated usage of materials, etc. The queryTagHistory function allows users to span time frames in a flexible manner. But if one wants to have for instance values that are per month, how would this be configured? The query doesn’t have any knowledge of this kind of date/time information. Example below: Start time: 2019-01-01 00:00:00; end time 2019-03-31 23:59:59; etc.


JAN 2019 11.5 20.5 25.6

FEB 2019 13.3 21.5 30.0

MAR 2019 12.2 22.0 29.9

thank you!

Check out the code examples here:

This function lets you generate a dataset with many combinations of aggregates and time frames.

1 Like

Thank you. I am thinking I’ll have to use some system.date functions to break the history queries into discrete chunks by month then assemble the data …

Sure. You can also span multiple months with that function. Just make a test window and put the results in the data property of a power table and you will see what I mean.

1 Like

Here is the issue I am facing. The table below is generated with an aggregation period of ‘month’ and a duration of 12 months. However, a month when defined as a fixed period of minutes gives this result seen below, with the dates moving around during the reporting, not actually a month each…


Try using this one and see if it works better.

Is your client running in the same time zone as your server? I’ve seen weird things happen with data queries when a perspective session queries data from a server that’s in a different time zone than the session is being run from.

I’ve only been using these calculations to return data for a single group so I can’t speak to how the aggregate grouping works. My understanding was that you either use the start and end date properties or you use the interval hours/minutes properties. The documentation says you can use them together so I’m a little confused.