Forum Academy Marketplace Showcase Pricing Features

Advanced grouping and aggregating without 'Workflow on a list'?

Hi there,

I am totally new to Bubble, hence would really appreciate your help here!

What I want to achieve: I am trying to generate a shopping list of ingredients based on a number of selected recipes. The shopping list should be aggregated across same types of ingredients (i.e. 2 apples + 1 apple = 3 apples, etc.) as well as sorted according to categories (i.e. apples under the header ‘fruit’, carrots under the header ‘veggies’, etc.)

I have achieved these first two step by using repeating groups with different grouping and aggregation options.

The complication is, that for each recipe, a user might want to select a different multiplier (i.e. recipe A contains 1 apple, recipe contains 2 apples - however recipe A should be cooked for 2 servings and recipe B for 3 servings and hence the total amount of apples should be 12 + 23 = 8).

In the current set up, I cannot link the multiplier per selected recipe to the quantity of each ingredient without losing aggregation across different recipes, i.e. as soon as I add Selected Recipe as part of the Grouping, ingredients belonging to different recipes show up as individual line items.

My relevant data-structure looks as follows:

  • Recipe (includes overarching recipe info, e.g. name, prep time, etc.)
  • Selected recipe per user (includes multiplier per recipe and uniqueID of the original recipe)
  • RecipeIngredient (describes the individual ingredient (e.g. quantity, name, etc) per recipe, linked to mother recipe via uniqueID)

Current assumption for a solution: Do I need to generate a new data type (Shoppinglist_Item) which includes as ‘new_quantity’ = ‘multiplier’ * ‘original quantity’ and run the grouping and aggregating on that? However to do so, I have to generate many new shoppinglist items when selecting a new recipe by running ’ Schedule a Workflow on a List’.

My question: Is there a better way to do this by setting up my data structure differently, or do I need to indeed figure out how the ‘Workflow on a list’ works?

Following! This is actually very timely and I think the ability to aggregate over foreign keys would be huge!

Have you used bdk rg tools data extractor or the bdk utilities plugin? Sounds like a good use case here ^^

I have and actually use it in a different part of my app!

I ended up solving the problem with the “Orchestra” plugin from @vini_brito and implementing a left join as described.

The BDK plug-in is a nice option for tiered data extraction (IMO) but doesn’t solve the left join problem (for anyone reading this later - the left join RG trick is awesome!)

1 Like