Calculate Monthly Average Data in Bubble App

In my Bubble app database, I have stored different emails for a brand along with their date, subject line, content, etc.

Now, I want to display the monthly average count of emails based on the date range selected within the date picker.

I thought of basically finding the number of days between the date range and then dividing that number by 30 to determine the average month.

And finally divide the total email count during that date range by the average month number to get the approximate monthly average email.

For this, I am using a formula like this:

Search for email within the selected date range: **count /**date picker range:**end date - ** date picker range:start date/30


However, this is not giving me the expected calculation as it feels that in the last it is not dividing the number of days by 30.

Is there any issue with the formula that I have written? Any better approach to solve this use case?

To display the count, just take the search for emails count as you have it in the beginning of the expression.

Doesn’t make any sense because the monthly average would imply you are looking at the entire YEAR and dividing by 12 to get the average monthly count of emails sent, but in your screenshots and explanation you are attempting to show an average daily count of emails sent if you are taking the number of emails sent within the range and dividing by 30.

What are you really trying to do and for what use case other than displaying the value?

So, basically, i am tracking the email newsletter of a brand sent on different dates.

Now, I want to display three metrics:

  1. Total number of newsletters sent - self-explanatory, i have use count function and it worked.

  2. Average number of monthly emails sent - I want to show the average monthly newsletter sent by an email based on the date range a user is looking to analyze the data. I know this can never be accurate unless someone has selected the whole months in the date range but the approximate number will also work.

  3. Average email sent in a week: Similarly, I want to display the average number of newsletters sent by a brand in a week based on the date range a user is analyzing.

Need to force the date range pickers to be month based instead of single dates, because, how could you accurately provide a monthly average if the user selects dates that are just 1 week apart. But if you just want to keep the feature as is with two date pickers, then consider the idea that the user might just choose a week range, you need to know how many days in their selection (ie:7), then you take the count and divide by 7 and then multiply by 30 to get an assumed monthly average.

Same thing…if the user selects 3 days in the range, take the count and divide by the number of days in the range (ie: 3) and then multiply by 7

This topic was automatically closed after 70 days. New replies are no longer allowed.