Conditional Rollup within Glide data editor

Wondering if anyone has successfully used the rollup column in the data editor meeting certain conditions?

I know this can be done with some spreadsheet magic, but would love to minimize as many google sheets formulas as possible.

Specifically, I’m creating a cart, and would like to sum up the price for cart items only for the specified user.

Yep. Create the relation first, then Rollup the relation.

1 Like

@Robert_Petitto

Let me expand and let me know if I’m missing something.

I want to create a rollup to count the sum of a quantity of items from a relation column ONLY IF a certain condition is met in an adjacent column.

For my use case, I’m matching inventory (cart items) and I only want to count inventory of the items whose orders are marked as paid. I’m indicating whether or not an order is paid with a boolean.

I have a rollup now on the total quantity of the item the user adds to their cart, but it counts all orders, which could be cancelled or not yet paid for by the user.

For the “if paid” boolean, instead of resulting in true/false, result in item name/blank. Then do the multiple relation to the if-then column and then the rollup should be accurate.

2 Likes

Done. Thanks for reminding me of this!

1 Like

I have a variation on conditional rollups and I’ve read some of the related posts but I’m still stumped.

It’s for machine maintenance tracking.
One-many relationship between machines and maintenance log
Every log record has a date, but only some have a meter reading

I need to know the most recent meter reading (log has meter is true) and the date of that log record. I was using rollups of maximum meter reading and latest date, but realized that was incorrect. I need the actual date of the maximum meter reading.

Would love to hear from anyone about this!

In your log sheet create an if then column and fill it with true if the log has a meter reading greater than zero. Then create a template that joins the machine ID and the if then value. In your machine sheet, create a template of machine ID and the word ‘true’. Now change your relation to use those templates to link machine to log. Your rollup should then show the max date of a log that has a meter reading.

3 Likes

Thanks, Jeff! That works like it should. I’ve read your answers many times, but this is the first time I’ve been the one asking the question. I really appreciate the way your brain works and how much you share on this forum.

3 Likes

@Robert_Petitto I followed this, almost. I am trying rollup based on user and date. Same concept as with shopping cart. There is a list of dollar amount values and I want to sum by user and by date. Grateful for a few more breadcrumbs. Thank you.

So you want to get a total dollar amount per user per date or just total per date?

On second thought, once the app is running, each user will be logged into his/her own account, so the sum only needs to be by date (date is a column). So, each transaction record includes user, date, amount. Thank you.

@Robert_Petitto I read a bunch of your other (quite instructive) material and cracked this. Thank you for making me think.

1 Like

Glad I could help! :grin: