Calculating count % change over 30 last days

Hi Commu!

Quick question regarding a percentage change display over a period of time, must be very easy to solve from some of you:

Im just trying to display the percentage change of new users over the last 30 days compared to the previous 30 days.

Any formula that might help?

Divide the count of one search of Users by the count of another search of Users:

  • Numerator: use the constraint Created date is greater than or equal to 30 days ago
  • Denominator: use the constraint Created date is less than 30 days ago

Thanks a lot for you reply @davidb , I’m not sure witch formula using for acheving “30 days ago”, can you please developp a little bit more?
cap

First of all, for the Created Date constraint you don’t want to use the = operator, but rather one of the less than or greater than operators.

As for the expression, here’s a mockup: Current date/time + days: -30. See the +(days) operator.

@davidb legend mate, works just perfect :sunglasses:

@davidb i encounter a problem with those conditions, whenever the percentage would be negative, it just displays 0%
Capture
Do you have a solution for that?

I would store the delta between the two calculations and divide it by the count of 30 days ago. In this case it works always.

Better stil if you need a lot of these dashboard metrics is to think about a platform like metabase. Doing “do a search” in Bubble is very expensive.

We offloaded much of our data to Supabase and have a analytics server running om which we subscribe the server to the logical replication publisher which is the Supabase db.

This way we always have real time dashboarding which hardly cost anything, no Workflow uses and no impact on production.

1 Like

@sem very interesting indeed when you need to display a lot of those metrics. In my case, i only need to display 3 metrics like these on my dashboard so offloading this data at the moment is probably not important.

However the idea of storing the result to divide it by the count of 30 days ago is interesting.

How would acheive that? I’m not sure to understand whether you need to create a new data type or so to have this value (result of the calculation / 30 days ago’s count) always updated in real time.

Looking forward to hear back :slight_smile:

You can add a custom state in bubble to save the number id 30 days again, that of now and the difference and even the percent change. This way you can use it everywhere without having to write the whole query all the time. You can read more about custom states in bubble in the documentation of Bubble.

It might also be interesting to have a analytics table in which you have some analytics data. Which you populate each day at a specific moment. Things like number of thing a, b and c. This way you will probably use less workflow units as you only do the “do a search” once. Upon setting the analytics row. When done like this you can always check that table rows and run the calculations. It also gives you a snapshot every day about important things.

1 Like

Thank you very much for your replies @sem I’ll give it a go :slight_smile:

1 Like

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