# Daily average of current

**URL:** <https://forum.inductiveautomation.com/t/daily-average-of-current/60276>\
**Category:** Ignition\
**Tags:** ignition81\
**Created:** [June 1, 2022, 7:38pm UTC](https://forum.inductiveautomation.com/t/daily-average-of-current/60276 "2022-06-01T19:38:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Finn.MP](https://avatars.discourse-cdn.com/v4/letter/f/da6949/32.png) [@Finn.MP](https://forum.inductiveautomation.com/u/Finn.MP)\
**Post date:** [June 1, 2022, 7:38pm UTC](https://forum.inductiveautomation.com/t/daily-average-of-current/60276/1 "2022-06-01T19:38:37Z")

</div>

I am trying to display a graph and table that shows the average current of a motor for each day. I’m wanting to show this data over a month to see if the motor current is increasing. I created a SQL database that triggers the value every hour. I can show the data in a graph but there are so many peaks and valleys that you can’t get a good visual of the increase of current and that’s why I want an average. A SQL tag binding on the graph doesn’t give the option to display an average. How can I create a SQL query that finds the daily average of the motor current?

---

<div class="post-metadata">

**Author:** ![swolnisty](https://avatars.discourse-cdn.com/v4/letter/s/7bcc69/32.png) [@swolnisty](https://forum.inductiveautomation.com/u/swolnisty)\
**Post date:** [June 1, 2022, 7:52pm UTC](https://forum.inductiveautomation.com/t/daily-average-of-current/60276/2 "2022-06-01T19:52:29Z")

</div>

Assuming you are already historizing your current tag, I would probably use scripting to return this data rather than a SQL query. Something like this would likely get you in the ballpark:

```auto
paths = ['[default]Some_Device/Current']
endDate = system.date.midnight(system.date.now())
startDate = system.date.addDays(endDate, -30)

system.tag.queryTagHistory(paths, startDate, endDate, aggregationMode = 'SimpleAverage', intervalHours = 24)

```

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [June 1, 2022, 9:58pm UTC](https://forum.inductiveautomation.com/t/daily-average-of-current/60276/3 "2022-06-01T21:58:14Z")

</div>

I suspect that you are going about this the wrong way. If you have a load that fluctuates then you would need to filter or average the readings more frequently than your OPC scan rate might allow. A better fix would be to install an energy meter and record the total kWh periodically. From that you can calculate the average power drawn per minute, hour, day, week, etc. much more accurately.

If you can’t do that then see what averaging you can do at source before collection by Ignition.
