Formula Help - Getting a bulleted list from 2 tables and one condition

Hello! Longtime follower, first time asker:

I have a Coda doc for keeping track of what’s in my pantry and what recipes I can make from what’s in stock. The doc contains 2 tables: one of food items (“Whole Pantry” table) and one of recipes (“Recipes” table).

Can I get a bulleted list of all recipes, classified by a type (e.g. dinner), based off of what ingredients are in stock? For instance, if I have all the ingredients in stock to make, say, Fajitas, then that recipe would be listed.

This is what I have, but it doesn’t work:
Recipes.filter(Type=Dinner)AND Whole Pantry.filter(In Stock=true).BulletedList()

I’ll add that I don’t think this formula would work because, tho it is filtering only one 1 type of recipe (e.g. dinner) and what ingredients are in stock, there seems to be a missing component to linking them. Like, I feel like it needs some kind of logic:

  • first check to see what ingredients are in stock
  • then check these ingredients against all recipes
  • filter recipes based on “dinner”
  • produce list of dinner recipes that can be made of what’s in stock

Eh?

Do you have a sample doc that you can share here? Much easier to work if we can see your setup.

Sure @mallika - just shared with you, thanks!

Hey @Saul_MIND_Garcia - thanks for putting this together!

Ideally I’d like to have only ingredients and have the formula check to see if ingredients are available, and then suggest the recipe. Is that possible?

Here’s my doc:

Hi @Jon_Schafer , I added a section called Search in your doc. Can you see if these options work for you and you can build on it and format it.

The steps here are -

  1. Create a Multi Select List to select ingredients from
  2. Filter the Recipes table using one of these filters ( depending on what you want)
    Contains at least these ingredients -
    Table filter - Ingredients.ContainsAll(ItemSelect)
    Contains all of the ingredients selected -
    Ingredients.ContainsOnly(ItemSelect)

Let me know if this helps

Hmm. That’s a lot like Saul’s above which is helpful, but not quite what I’m after. If it helps, this whole started from this template: https://coda.io/t/Pantry-Recipes_tWHNAR9EljR

In that template, the creator has a formula that does what I’m after but I simplified my doc bc my needs aren’t as complex. Here’s the formula they used for generating the list of the Your Pantry section:

[Your Recipes].filter(AND(Available="True",contains("Lunch",Type))).nth((if(round((count([Your Recipes].filter(AND(Available="True",contains("Lunch",Type))))*Randomizer.[Column 3].Nth(1)),0),round((count([Your Recipes].filter(AND(Available="True",contains("Lunch",Type))))*Randomizer.[Column 3].Nth(1)),0),1)))

Got it.

I like using columns in tables so my solution is a little different.

I changed the Ingredients table to a Lookup.
Then added a column to see what ingredients are available.
If all are then Can Cook is true.
You can then use Recipes.Filter([Can cook?]).Name.BulletedList() to get all the recipes you can cook.

Can you take a look at the doc and see if this is any better?

I think I get what you’re after, check this copy of your doc I made.

Hey - thanks for the nudge on Intercom - this TOTALLY works. I love the elegance of an “available” column and then the simple math to say if you can cook it. Thank you SO much for working with me on this!

Thanks again for the examples Saul! Mallika’s version works best for me. Appreciate you working with me on this!

No problem man! Glad to help :slight_smile:

1 Like