Time Weighted Average

This might be a better question for Stack Overflow, however I was curious if anyone here has ever delt with this issue.

I have a client who wants to use a third party web-dashboard for viewing historical data. They are concerned about making sure they are getting good averaged values, however the data is stored from Ignition as it changes without any sort of consistent time gap. Is there a direction I can point them in to have their SQL queries take the duration a tag was at a certain value into consideration, or is their only recourse the AVG command and accepting any skewing that may occur?

They can use the SQL lag() window function to give you the timestamp preceding a sample, from which you can compute a weight for that sample. If you want to minimize difficulties with external tools, use transaction groups to record into wide tables on fixed intervals.

2 Likes

Have you considered having the third party application ask Ignition for the data via the WebDev module and system.tag.queryTagHistory ?

1 Like

I had not heard of the lag function in SQL. That looks extremely promising for their application.

I had not considered system.tag.queryTagHistory, it wouldn’t work for their situation, but I will be bookmarking that for my own information, thanks!

1 Like