excel/google sheet - arrayformula for cooking planner - google-sheets

so i make this "cooking planner" by using 2 resource data (recipes, and cooking planning),
the "recipes" (cell A:C) data row will be added continuously whenever i have a new recipes.
therefore the recipes in "cooking planning" (cell E:M) data row will be added automatically too according the "recipes" data (in cell A:C)
then i have this "ingredient requirement" cell (cell E10:M16) that will count all the ingredient of the recipes combined (currently using vlookup)
but whenever i add a new recipes, i have to edit the old vlookup formula (adding a new recipes) and the formula gotten too long.
can it be done using arrayformula or any shorter formula?
thank you before.
google sheet link :
https://docs.google.com/spreadsheets/d/15mP1q_Qia-CADqqn7mzbKwIS5YrGv4W4iqyUEpqfVWY/edit?usp=sharing
i tried using vlookup formula, but whenever i added a new recipes, i must add new vlookup formula for each recipes.
can it be done using arrayformula where it will add automatically when i added new recipes?

I've added a solution in a new tab. please do test it out and lemme know of any misses.
cells with blue have formulas accommodated.

Related

How can I exclude a row from a formula based on a value of one cell in it in Google Sheets

I am working on a spreadsheet for a project that involves listing five ingredients for a recipe, along with a number value of how many of that ingredient is needed. I am then using functions in Google Sheets to automatically create a list of all unique ingredients and how many there are across all rows, broadly seen here:
enter image description here
For the "Ingredient List" I am using the code:
=SORT(UNIQUE(FILTER(FLATTEN(E4:E, G4:G, I4:I, K4:K, M4:M), FLATTEN(E4:E, G4:G, I4:I, K4:K, M4:M)<>"")))
And for the "#" column to the right of it I am using the code:
=IFERROR(SUM(FILTER($F$4:$F,O4=$E$4:$E)))+IFERROR(SUM(FILTER($H$4:$H,O4=$G$4:$G)))+IFERROR(SUM(FILTER($J$4:$J,O4=$I$4:$I)))+IFERROR(SUM(FILTER($L$4:$L,O4=$K$4:$K)))+IFERROR(SUM(FILTER($N$4:$N,O4=$M$4:$M)))
What I would like to do is to make so that if the value in column D ("Obtained?") is "Yes", then the entire row (E-N) is excluded from the two lists in columns O and P, but I do not want anything to be deleted. This would allow me to depopulate the "Ingredient List" as additional rows are marked "Yes", theoretically until a point where it is empty.
Is this something I can plausibly do using the tools within Google Sheets, and if so, how? Thank you!
I've tried some variations of "If" or "Ifs", but I need it to check every cell in one column from one cell (O4 and P4).
Can you try this in Cell O4. you may need to clear the exsiting formula(s) in columns O & P to let this formula freely expand.
=let(a,filter(E4:N,D4:D="No"),b,tocol(choosecols(a,1,3,5,7,9),1),c,tocol(choosecols(a,2,4,6,8,10),1),byrow(unique(b),lambda(z,{z,sum(filter(c,b=z))})))

Google Sheets formula to leave cell empty based on conditions

I'm having issues with this formula:
=ARRAYFORMULA("WORD"&" "&sheet1!$B$20&" "&'sheet2'!A2:A&" "&sheet1!$B$17&'sheet2'!B2:B)
What I want is to leave empty cell if there is no data available in sheet 2 and when the data is added in the sheet (sheet2) the formula auto populates the results in the third sheet, where the formula is placed.
Tried with If function, but I'm getting Errors.
Thanks in advance for the help.
=ARRAYFORMULA(IF('sheet2'!A2:A="","","WORD"&" "&sheet1!$B$20&" "&'sheet2'!A2:A&" "&sheet1!$B$17&'sheet2'!B2:B))

Conditional Formatting & Importrange using 2 spreadsheets

I am requiring specific cells of a Google spreadsheet to be conditionally formatted based on information in a different spreadsheet.
The information is input into column J of a spreadsheet titled 'Haulage' and in a worksheet with the same name. I then require any cell in the range AE15:AH101 in a spreadsheet titled 'EMU Database' and in a worksheet titled '350' to be highlighted in a colour should the information in this cell match the information input into column J of the 'Haulage' spreadsheet/worksheet
ie '271' is in cell AE15 of the worksheet '350' (in 'EMU Database' spreadsheet) and when I input the same value into cell J3 of the worksheet 'Haulage' (in the 'Haulage' spreadsheet), AE15 is highlighted in the chosen colour.
I have tried using the following formula in the conditional formatting custom formula:
=A15=IMPORTRANGE("1AGMJxw5D5TNFI19dvpPCT0Jl6QNu5rRX1bcLqHYJ0-w", "Haulage!J3:J")
But not been able to make it work unfortunately.
For reference, both of the spreadsheets have been linked together and access has been granted between the 2 spreadsheets
Progress report:
I have been playing around with the importrange options in making this conditional formatting work and I have managed to get it to work by importing the data into the same spreadsheet and then using a formula between worksheets as detailed below:
Data from "Haulage" spreadsheet and "Haulage" worksheet within this spreadsheet is transferred to "EMU Database", into a worksheet titled "Sheet5" using the standard importrange function. In the cells I require the custom formula to work I have then used the following custom formula:
=match(AE15,indirect("Sheet5!A1:A"),)
This offers a solution to my problem and works as I require it, however I would still like to find a solution to avoid having to transfer the data from one spreadsheet to another before the formula works. I have tried to amend the above formula in a number of ways to incorporate an IMPORTRANGE but without success. My most recent failing is below:
=match(AE15,indirect,importrange("1AGMJxw5D5TNFI19dvpPCT0Jl6QNu5rRX1bcLqHYJ0-w", "Haulage!J3:J"),)
If anyone has any ideas on how to make the importrange work on this match formula it would be appreciated as it keeps things tidier for me than having extra worksheets with duplicate data from another spreadsheet
Follow up information for #player0
Links to the test versions of the relevant spreadsheets are below:
Haulage SS = https://docs.google.com/spreadsheets/d/1elDxSOLSG-6U-jC6E5fgcKeJDNf9Kcu7GRGvK5p6fr4/edit?usp=sharing
EMU Database SS = https://docs.google.com/spreadsheets/d/1poWzun1TvIhdlrHQyM_tSvJzEHFDpvZz7O-Ta0mvAR8/edit?usp=sharing
Within the "Haulage" spreadsheet, only the 'Haulage' worksheet is of interest - please disregard the other worksheet.
Within the "EMU Database" spreadsheet you will find my current conditional formatting in cell range AE15:AO71 of worksheet '390'. This formatting is linked to the worksheet titled 'Sheet5' which contains the data that I have used the importrange formula (see cell A1 of this worksheet) to pull from cells J3:J of the Haulage spreadsheet.
Basically, what I require of the conditional formatting is for any data in cell range AE15:AO71 of the '390' worksheet which matches data entered in cell range J3:J of the "Haulage" spreadsheet to be highlighted with a coloured box - but I want this to happen without the need for the extra worksheet with the imported data in
try:
=MATCH(A1, FILTER(
IMPORTRANGE("1elDxSOLSG-6U-jC6E5fgcKeJDNf9Kcu7GRGvK5p6fr4", "Haulage!J3:J"),
IMPORTRANGE("1elDxSOLSG-6U-jC6E5fgcKeJDNf9Kcu7GRGvK5p6fr4", "Haulage!J3:J")<>""), 0)

How to insert row with formula that links cell? Google Sheets API

The answer is next:
1) There is formula in Google Sheet cell "A11", for example "=F11+C11";
2) I append multiple data to this Google Sheet list with the help of
https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/batchUpdate
or https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets.values/append
3) I need to append the value for "A12" using its current position. It had to become "=F12+C12".
Or if I append data on top
(as described here - Google sheets API append method (last on top))
I need that formulas under my append changed to correct value. If current value of "A11" is "=F11+C11" then,
if I add 3 rows before this row, it becomes "A14" cell and it's value had to be changed to "=F14+C14"
Is there any way to realise both this scenarious directly in Google Sheets API request? May be there is some settings in Google Sheet that can help me (something like formating of cells/columns etc)?
UPD. For now it all works fine except of that incident when formula returns exception! My questions is not actual for now, but I still not understand in which cases formulas will change and in which they will not.
The answer is quiet simple!
I update cell 'A13' with formula '=B2+C2' and as cells 'B2' and 'C2' stay on their places after every changes my cell 'A13' still link cells 'B2' and 'C2'.
But if I will add row before 'B2' and/or 'C2' then formula will change and my cell 'A13' will link 'B3' and 'C3'.

How can I apply a formula to new, form-inserted rows of data in Google Spreadsheets?

I would like my Google spreadsheet to automatically apply formulas found in cells F2 to H2 to all new, form-inserted rows. You can view the spreadsheet here.
The formulas are:
F2: =IF(B2, "I"&B2,"--")
G2: =vlookup(C2,SectionID!$A$2:$B$13,2,FALSE)
H2: =vlookup(D2,ReporterID!$A$2:$B$12,2, FALSE)
I have tried manually applying the formulas to rows 3 to 10, but when a form is submitted, the data is added to newly created rows which do not contain the formulas. (Form data is submitted to columns A to E.)
Feel free to make changes to the spreadsheet.
Thank you for your help.
You will need to either use a script to populate the formulae on form submission, or use the out-of-the-box solution which is an array formula:
=ArrayFormula(IF(A2:A;IF(B2:B;"I"&B2:B;"--");IFERROR(1/0)))
=ArrayFormula(IFERROR(VLOOKUP(C2:C;SectionID!$A$2:$B$13;2*SIGN(ROW(A2:A));FALSE)))
=ArrayFormula(IFERROR(VLOOKUP(D2:D;ReporterID!$A$2:$B$12;2*SIGN(ROW(A2:A));FALSE)))
Here is a bit of discussion about the trick involved in converting VLOOKUP to iterate down an array.
You can also invoke formulae in row 1 to populate the headers as well, which mitigates against the scenario where a row might be inserted above row 2:
=ArrayFormula(IF(ROW(A:A)=1;"IssueID";IF(A:A;IF(B:B;"I"&B:B;"--");IFERROR(1/0))))
=ArrayFormula(IF(ROW(A:A)=1;"SectionID";IFERROR(VLOOKUP(C:C;SectionID!$A$2:$B$13;2*SIGN(ROW(A:A));FALSE))))
=ArrayFormula(IF(ROW(A:A)=1;"ReporterID";IFERROR(VLOOKUP(D:D;ReporterID!$A$2:$B$12;2*SIGN(ROW(A:A));FALSE))))

Resources