Number comparisons for percentage display (positive / negative)?

I want to create a way to display a percentage increase/decrease of a collection of the past 30 days.

For example, let’s say we have 120 users and 20 of them signed up in the last 30 days.

I’m able to get the percentage with a calculation, that’s the easy part. 120 - 100 / 100 * 100. = 20% (end value - starting value divided by starting value times 100). Users count minus users count with filter created before 30 days ago divided by users count with filter created before 30 days ago times 100.

My question is, how can I use this number to display the increase and decrease by visibility setting? I want to display a green positive increase text if the increase was a positive increase and red if it was negative. Like so:

Screen Shot 2022-04-29 at 12.28.01 PM

We can’t use the number type input as comparators. Maybe I’m overthinking it.

I did create a feature request to allow Input components set as a number to allow comparisons.

Hi @Flawless ,

What I would do is to have additional temporary field in users collection that indicates plus or minus.

This field will be updated as 1 when ending value is greater than starting value, as 0 if otherwise, something like this.

Thank you for the input @Yongki I appreciate ya :sunglasses:

Well, after a good couple of hours of playing with it, I figured out a way. Not sure why this one was messing with me so much lol.

I added a new collection called “Statistics” with a name and 3 number parameters. I send the user to a loading screen with a countdown timer within a list that updates the statistics. Luckily, I only have 3 records that need updating prior to the next screen.

This way I put together works but it would be so much easier if we could just use the input components and compare values of 2 numbers.

Result in the demo:

2 Likes

That is wonderful.

Previously I was using lots of input component for temporary, even dedicate a whole screen for that, but since the engine change how it works, I would prefer the users collection field for that.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.