Data analysis for average number of people at gym

I posted this on the influxDB forum and was told this would not work so I am posting it here to get a different perspective.


Using flux in influxdb, I would like to estimate the average number of people at the gym based on previous history on Monday-Sunday. I am using home assistant and my local gym has the number of people currently at the gym and I am constantly pulling data from that. So what I would like to do is for each day of the week, use the corresponding collected data and calculate a moving average of some sort that corresponds with their operating hours. Lets take Monday for example. I would like to filter out all data except for Monday, then filter out all times they are not open (they are open from 5am-10pm) then I would like to use the data I have collected and calculate the average number of people every 10 minutes so I can see a line graph of when it is most busy/ least busy. Then I would like to repeat this for every day of the week. Fridays, Saturdays, and Sundays all have different hours so I may have to do it in separate graphs. Google does something similar to this as an example.

Also, I found a thread kind of like what i need but it did not produce exactly what I wanted…
Average per hour - #14 by MarioG (the comment by mariog)
Is this possible? I have been trying to figure this out for the past few days with no success. Thanks!