# Calc average value in Report

**URL:** <https://forum.inductiveautomation.com/t/calc-average-value-in-report/54136>\
**Category:** Ignition\
**Created:** [December 15, 2021, 6:27am UTC](https://forum.inductiveautomation.com/t/calc-average-value-in-report/54136 "2021-12-15T06:27:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![chaoliang](https://avatars.discourse-cdn.com/v4/letter/c/ba8739/32.png) [@chaoliang](https://forum.inductiveautomation.com/u/chaoliang)\
**Post date:** [December 15, 2021, 6:27am UTC](https://forum.inductiveautomation.com/t/calc-average-value-in-report/54136/1 "2021-12-15T06:27:50Z")

</div>

I want to calculate the average value of a historical value within 24 hours, but this value may sometimes be 0 when the equipment is not running.  
Is there any easy way to perform the correct calculation by removing the value (0) from the calculation?  
if I want to use SQL to calculate the average historical values, which data table should I refer?

Select avg(tagvalue)  
From table???  
Where (tstamp between time1 and time2) AND (tgavalue \> 0)

---

<div class="post-metadata">

**Author:** ![lachguerabdallah](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lachguerabdallah/32/25558_2.png) [@lachguerabdallah](https://forum.inductiveautomation.com/u/lachguerabdallah)\
**Post date:** [December 15, 2021, 8:55am UTC](https://forum.inductiveautomation.com/t/calc-average-value-in-report/54136/2 "2021-12-15T08:55:20Z")

</div>

you can use scripting to filter the data and generate a new dataset without the null values  
[https://docs.inductiveautomation.com/display/DOC79/Scripting+Data+Source](https://docs.inductiveautomation.com/display/DOC79/Scripting+Data+Source)
