Display % change month to month

Hey!

So, basically, our app allows users to parse information, and it saves each parsed item in the DB as a “parse”.

In our dashboard, we show those parses in a graph, month by month, and that works perfectly.

Now, the part where we got stuck is in trying to also display, in the dashlet that contains the graph but OUTSIDE the graph, the percentage change in parses created from the last month to the current one.

Meaning, if someone created 10 parses in July, and 20 in August, it should show 100%, or 50% viceversa.

I’m trying with groupings and the such, but I’m super stuck and can’t find the way to do it!

It only needs to happen from last month to the current month.

Why dont you calculate it yourself? Just do: (this month's parses count - past month's parses count ) / last month's parses count * 100

That is exactly what we’re trying, but we’re having issues with the “this month’s parses count” and “past month’s parses count”.

We’re grouping the parses by month, but I fear we’re messing up somehow
Screenshot 2024-08-31 110304

You will not use group by in this case. You should find this and last month’s in the constraints of the Search for Parses and the final expression will look like:
(Search for Parses:count - Search for Parses:count) / Search for Parses:count

The first Search for Parses will have creation date to be between Current Date/time and Current Date/time:rounded down to month (to find this month’s Parses).

The second Search for Parses will have creation date to be between Current Date/time:rounded down to month and Current Date/time:rounded down to month +months: -1 (to find previous month’s Parses).

Also recognize the paranthesis in the expression. You should do the subtraction first. And for this, you should enable paranthesis expressions in the settings tab.

I’m following what you’re saying, but I’m not understanding how I should define a date range in a search constraint. Should I use <-range->?

You will add two constraints with Creation Date in it. One will be the lower limit and one will be the upper limit. Check the example below for this month’s:
image

Didn’t know you could do it like that!

I’ve done the changes, but nothing is showing for some reason, here are the screenshots to my three searches
1
2
3

The conditions should be like below:

Works like a charm! Thanks!

While at it, since you already know the config for this element, is there a way to conditionally change the font color based on whether the number is positive or negative? I’m thinking no, right?

You can simply do the same calculation and put a condition to change the default color to something else.

A condition would be Search for Parses (first one above):count - Search for Parses (second one above):count > 0Change color.

Another improvement would be, if you don’t want to calculate this over and over again, maybe set This month's parses to a custom state on page load (and for the other too).

1 Like

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