Average of values for a particular datetime

I have many number of entries or records of data in a day I just wanted to show the average of value for a particular day on timeseries chart in perspective ignition.
I am not able to show the average value for a particular day.
Should we create a code for the same.

If your data is coming from a SQL query then you should use the SQL AVG() function to return the data in the format required.

I have used the SQL Avg function it is returning all the average data I just needed the specific one day data to show as selected.

Please show your SQL query.
Use the </> code formatting button to preserve code indentation and apply syntax highlighting.


You might consider grouping by the date:

   AVG(myValue) AS avgValue, 
   CAST(myDateTime AS DATE) AS dateOnly 
FROM myTable

This would give you the average value for each date in the table.
Or if you need a specific date:

   AVG(myValue) AS avgValue 
FROM myTable
WHERE CAST(myDateTime AS DATE) = '2022-01-01'

It would probably be best to parameterize the date value with a binding.


1 Like