Forum Academy Marketplace Showcase Pricing Features

Constrain by comparing one field to another within a thing

I have a repeating group listing all of a particular thing.
The things have two fields; each is numeric; Field A and B.
You want to show only the things where A > B.
How do you do that?

I’m displaying the items in a repeating group. I’m searching for all things of this type and want to constrain the data, comparing one field to another within each thing.

Seems simple, and I’m sure it is.

@jason1 - Here’s what you can do.

When you create your thing and assign a number to A and B, you should also create another field (in this case I’ve called it AB) which is the sum of A minus B.

Now, you know that if AB is a negative number then B > A. If AB is a positive number then A > B. Finally, if AB is zero, then you know A = B.

Then you can set up the following constraint on your repeating group:

If A and B are values that are going to change through usage of the app, then just remember to recalculate AB each time you change A or B. It’s only 1 extra step in each workflow.

Thanks, Andrew! I’ll go this route if needed.

Is it not possible to constrain repeating group search results by comparing two fields within a thing?

NigelG solved it in a post I found after another round of searching. Super simple.
https://forum.bubble.io/t/flitering-in-repeating-group-from-bubble-db/3187/2?u=jason1

Filter the results using Advanced: This Item A>This Item B

@jason1 Aha! Was looking for a way to do that…never made it to the advanced filter though.

Glad to know this for the future. Thanks @NigelG

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