Constraint to only show the largest number from an option set

Stuck on this. I have a graph that I only want to show the most recent “reporting period”, so as I continue to upload data, it will only show the latest data.

I have an option set that determines the reporting period “1-4” and another for year “2020 - 2022” and need the constraint to allow the graph to only show the highest number / last reporting period.

Any thoughts on how to structure this logic?

There are a number of different ways you can tackle this logic but I’m going to give you an example and you can tweak it as best fits your solution.

First, you are 90% of the way there! One note, I added an attribute to the option set which is a data type number to make it easier to accurately find the most recent item. This isn’t necessary, but since option sets are static it isn’t difficult to add a number attribute. The attribute will represent the order (i.e. 1-10 where 10 is the most recent option added to the set and the next option added would have an attribute 11). What I will show you can be done by sorting on the dates without the additional attribute on the option set.

In your image select the “=” sign and then you will select “Get an Option”

Then select “All Options”.

Screenshot 2022-08-12 at 12.20.02 PM

Next, you want to sort these items (by your date or in my case the number attribute I mentioned above) and be sure to select desc = yes. This will make the most recent items added appear first so in the example (11, 10, 9 etc, 1).

Screenshot 2022-08-12 at 12.19.08 PM

Now you only need the first item (the most recent item) so select “:first item”.

And that’s it and it makes a lot of sense when you think about it right?! This is what I like to think about as “Bubble Magic”. This is the kind of functionality that puts Bubble on a playing field that no one else is close to right now in terms of low-code options.


Ah, “Get an Option” thanks so much! I completely forgot this was an option. Bubble really is on another level.

Thanks again!

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