How can I use Excel or Google Sheets to make an automatic recipe calculator?
For example, the original recipe is specified in columns A-C:
The original recipe is 200g flour, 100g sugar, 50g margarine.
If I fill in D2 with the amount of flour I want to use, 400g, I want to be told I need 200g sugar and 50g margarine.
I will always only specify one quantity.
I would like the results to be presented in a table in the spreadsheet.
I have one solution that presents results in an extra column. These are the cell values of that column:
=A2*FILTER(D2:D, NOT(ISBLANK( D2:D )))/FILTER(A2:A, NOT(ISBLANK( D2:D )))=A3*FILTER(D2:D, NOT(ISBLANK( D2:D )))/FILTER(A2:A, NOT(ISBLANK( D2:D )))=A4*FILTER(D2:D, NOT(ISBLANK( D2:D )))/FILTER(A2:A, NOT(ISBLANK( D2:D )))
They use FILTER(D2:D, NOT(ISBLANK( D2:D )))
to get the "My quantity" value that is specified. Then FILTER(A2:A, NOT(ISBLANK( D2:D )))
gets the corresponding "Quantity" value. Those are divided for the ratio, and multiplied by the Quantity of the row.
I have three gripes with this solution: dragging the formula down to rows underneath does not autofill correctly (the D2:D
ranges etc. all get changed to D5:D
, which breaks it); it's very verbose; it doesn't present results in the "My quantity" column.
Can any of these issues be resolved?