• # Statistics Extensions

Would it be possible to do either of the following:

a) Find the average of a data point across a period for Mondays only? i.e.

``````<ma-point-statistics point="myPoint1" from="dateBar.from" to="dateBar.to" statistics="statsObj1"></ma-point-statistics>
<p>
The average value for Mondays in the period is {{ statsObj.averageif."Timestamp=Monday".value }}
}}
</p>
``````

I've tried a few techniques using moment filters but have had no luck.

b) Somewhat similarly, could you find the average of a data series if another series is equal to/greater than/less than another value for the corresponding timestamp? For instance:

``````<ma-point-statistics point="myPoint1" from="dateBar.from" to="dateBar.to" statistics="statsObj1"></ma-point-statistics>
<ma-point-statistics point="myPoint2" from="dateBar.from" to="dateBar.to" statistics="statsObj2"></ma-point-statistics>
<p>
The average value when myPoint1 is greater than myPoint2 is {{ statsObj.averageif."StatsObj1.value>StatsObj2.value".value }}
}}
</p>
``````

I think these Excel style operations would be really useful to visualise trends in data immediately.

Cheers, Henry

• @henryblu It sounds like you are going to need to write some specialized logic in JavaScript. I'd suggest adding a custom component via the user module, see https://help.infiniteautomation.com/getting-started-with-a-user-module/

You can leverage our `maStatistics` and `maPointValues` services to pull data from the REST API then process and output the data onto the page from the component. You can use the moment.js library directly inside your component, also we recently added the math.js library which might be useful. It has statistics and matrix functions.

Posts 2Views 580