How to calculate the average tag value per hour

Hello!
I need to calculate average value per hour and shield the sum of these values ​​per day, per month.Need to read the active power load graph with only active power. For example:
hour 1- 20kW
hour 2-25kW
hour 3-55 kW…
and summary of days
01.05.2020 - 160 kW
02.05.2020 - 170 kW
03.05.2020 - 150 kW
04.05.2020 - 180 kW
Summary per mouns 2550 kW.

1 Like

Hello!

Are you storing this ‘tag value’ in a database?

yes

This would be relatively easy to do using a tag history query system.tag.queryHistory.
With the results, you would need to do your calcs.

You could also do a SQL query directly to aggregate the data and return the results, however depending on your history partitioning setup (i.e. if you have partitioning enabled), you may need to union multiple tables together to get the data from previous periods (defaults is monthly partitioning).