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.
@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.
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.