Different amounts in different recipes

Hi!
I’d like to build a simple recipe database. I have different ingredients which are parts in different recipes but the various quantities are the problem. I saw an article about this in here but being a total beginner couldn’t quite understand what it meant.

So I have a table for ingredients and a table for recipes but how I set the quantities. Like:

Recipe #1
2 lemon
2 peppermint
2 lavender

Recipe #2
1 lemon
5 lavender
4 spearmint

So when I am saving my recipe I would like to choose the quantity for each ingredient and the quantity of course is a different one according to the recipe I’m saving to my database.

@Doterra_Kaisu

Check out meal-planner with good combination of recipes and ingredients by @Kamille_Parks
You will get many ideas for recipes.

Neal

2 Likes

Thanks for the shoutout, @nea_lpatil.

What you would need to do is make a third table to pair ingredients with a quantity, and associate it to a recipe. The base I made (linked above) does this using a table called [Recipe Ingredients]. Feel free to make a copy of that base to use for yourself! I can explain it’s mechanics further if need be.

3 Likes

Thank you so much ladies.:blush::heartpulse: I will follow your advice.

I’m sorry (and feeling very stupid indeed) but when adding new recipes where do I change the quantity so that it’s different in each recipe. Say I want to use 3 tbsb lemon juice in other recipe and 5 tbsp in the other.

You enter that in the new table. Every record is like a line in the Ingredients section of a traditional recipe in paper. And you have to link those lines with its recipe.

1 Like

If you’re using my example, you would input the quantities of each ingredient in the [Recipe Ingredients] table, which would look something like this:


Notice how each ingredient quantity gets its own “line”, and each one is linked to a recipe.

2 Likes

Greetings!
This question has been very useful to me, so thank you all!
In fact, I am currently using @Kamille_Parks base to create a cocktail-recipe book.
A new issue occurred to me while working on my base and thought that I could share it here instead of starting a new thread because chances are it could be useful to anyone reading this.
The thing is: in some cases, I would want to put not just an exact amount of a certain ingredient but I would rather put an interval of amounts, for example: 2 to 3 dashes of Angostura.
Any suggestions?
Thanks in advance, I really hope I’m not off-topic

I’ve kind of done this with the “to taste” option in the {Qualifier} field, which I use when there isn’t an exact amount of an ingredient used. You could also add “dash” to the {Unit} field

@Kamille_Parks this database solved many issues I had when creating a similar version. The only thing that I can not view is the original scripts used for leftovers and prepare. (I am on pro version, they just didn’t copy over). Can you, or anyone who got them to work, paste them in this thread so they too can be recreated. Please and thank you!

The “Prepare” script was:

let mealsT = base.getTable("Meals")
let mealsQ = await mealsT.selectRecordsAsync()
let meals = mealsQ.records

let recipesT = base.getTable("Recipes")

let today = new Date()
let todayS = today.toLocaleDateString()

let mealsF = meals.filter(x => {
    let date = x.getCellValueAsString("Date")
    let type = x.getCellValue("Meal Type").name
    return date == todayS && type == "Dinner"
})

let recipe = await input.recordAsync("Select a recipe", recipesT)

let meal = mealsF.length ? mealsF[0] : null

if(meal){
    output.markdown(`Recipe added to the meal: ${meal.name}`)
    let recipes = meal.getCellValue("Recipes")
    recipes.push(recipe)
    mealsT.updateRecordAsync(meal.id, {
        "Recipes": recipes
    })
}else {
    mealsT.createRecordAsync({
        "Date": new Date(todayS),
        "Meal Type": {name: "Dinner"},
        "Recipes": [{id: recipe.id}]
    })
    output.markdown(`New meal created`)
}

And the “Create Leftovers” script was:

let mealsT = base.getTable("Meals")
let recipesT = base.getTable("Recipes")
let recipesQ = await recipesT.selectRecordsAsync()

let meal = await input.recordAsync("Select a meal", mealsT)

let start = new Date(meal.getCellValue("Date"))

let mealRecipes = meal.getCellValue("Recipes").map(x => x.id)
let recipes = recipesQ.records.filter(x => mealRecipes.includes(x.id))

let yields = recipes.map(x => x.getCellValue("Yield"))
let minYield = Math.min(...yields) ? Math.min(...yields) : 2

for (let i=1; i < minYield; i++) {
    let x = new Date(start)
    let current = new Date(x.setDate(x.getDate() + i))
    
    mealsT.createRecordAsync({
        "Date": current,
        "Meal Type": meal.getCellValue("Meal Type"),
        "Recipes": recipes.map(x => ({id: x.id})),
        "Leftovers?": true
    })
}

output.markdown(`${minYield - 1} leftover meals added`)

@Kamille_Parks Thank you for such a quick response, you rock! I was just running some tests of the base to see how it behaves under certain circumstances. I noticed under shopping list, if two recipes use the same ingredient, but it is measured in different units, it will sum the quantity, and aggregate the unit. Any suggestions on which function I could edit to convert different units into one and return a sum decimal? (Not the end of the world, just trying to understand the logic pattern so I don’t mess anything up if I add functionality)

The answer would be to pick a universal unit, and create a formula which converts every possible unit of measurement to it. I didn’t feel like going through that headache, which is why it doesn’t exist in the base I shared.

1 Like