# Estimating average count based on day

**URL:** <https://community.influxdata.com/t/estimating-average-count-based-on-day/23276>\
**Category:** Fluxlang\
**Tags:** flux\
**Created:** [January 7, 2022, 2:41pm UTC](https://community.influxdata.com/t/estimating-average-count-based-on-day/23276 "2022-01-07T14:41:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Dohn](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/john_dohn/32/9175_2.png) [@John\_Dohn](https://community.influxdata.com/u/John_Dohn)\
**Post date:** [January 7, 2022, 2:41pm UTC](https://community.influxdata.com/t/estimating-average-count-based-on-day/23276/1 "2022-01-07T14:41:59Z")

</div>

Hello,

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.  
 ![image](https://us1.discourse-cdn.com/flex023/uploads/influxdata/original/2X/f/f4e0743f64588e48dfe300caa3d082c0006183fb.png)  
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](https://community.influxdata.com/t/average-per-hour/5966/14) (the comment by mariog)  
Is this possible? I have been trying to figure this out for the past few days with no success. Thanks!

---

<div class="post-metadata">

**Author:** ![Pooh](https://avatars.discourse-cdn.com/v4/letter/p/f05b48/32.png) [@Pooh](https://community.influxdata.com/u/Pooh)\
**Post date:** [January 7, 2022, 3:15pm UTC](https://community.influxdata.com/t/estimating-average-count-based-on-day/23276/2 "2022-01-07T15:15:49Z")

</div>

I hope someone else here can provide you with a helpful answer, but at first  
glance my feeling is that InfluxDB is not the best tool for this job.

InfluxDB is a data store, and although the Flux query language has a variety of  
useful operators and manipulation functions, I think it’s all a bit too “low  
level” for the type of statistical analysis and future prediction you’re  
trying to do.

Also, InfluxDB is a time-series database, meaning that it’s best suited for  
queries where you want to retrieve a series of data points based on timestamp.  
Picking out “all the values for Tuesdays 10:00-11:00” doesn’t really fit with  
that, because InfluxDB has no concept of a Tuesday (or a generic 10:00 for that  
matter). InfluxDB only knows that 1641895200 is _today_ at 10:00 (UTC), and  
seven days ago, or seven days into the future, is meaningless to Influx.

Regards,

Antony.

---

<div class="post-metadata">

**Author:** ![John\_Dohn](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/john_dohn/32/9175_2.png) [@John\_Dohn](https://community.influxdata.com/u/John_Dohn)\
**Post date:** [January 7, 2022, 3:19pm UTC](https://community.influxdata.com/t/estimating-average-count-based-on-day/23276/3 "2022-01-07T15:19:41Z")

</div>

Okay, thank you!

I will keep looking for a solution.

John
