How can I exclude a row from a formula based on a value of one cell in it in Google Sheets - 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))})))

Related

SUMIFS and ARRAYFORMULA within Google Sheets

I have a google sheet with multiple tabs, one of the tabs is for holding each observation of data while another needs to combine data based on certain criteria. I am trying to use a SUMIFS within and ARRAYFORMULA to get the correct information and it will only pull "0" no matter what I try.
I have set up a test google sheet with some dummy information to show an example of what I need to do in a more complex situation.
https://docs.google.com/spreadsheets/d/1JLyEuVijQ8MvfOKrtbRD_YKmRDnTCxf7qCSw9Ggty_Y/edit#gid=1250575550
In this example, the data tab is the individual observations and the sums tab is where I'm trying to pull combinations. I need column D to sum the totals in column E on the data tab if the Month and Year and Type all match what is on the sums sheet. In this example, cell D3 on the sums tab should equal 11.
you cannot use SUMIFS() in Arrayformula(), along with many other functions, though there is no formal documented list.
In your case you can use a SUMIF() instead by &'ing the condtions together.
I've demoed the concept on a new tab called MK_Help in cell D2:
=ARRAYFORMULA(IF(ROW(A2:A) = ROW(A2), "# TOTAL TYPE", IF(A2:A = "", , SUMIF(data!A:A&data!B:B&data!C:C,A2:A&B2:B&C2:C,data!E:E))))
Note that I made a couple of other small changes to your formula.
Namely, that you should always use a true "empty" instead of double quotes in your IF() mask up front tor return empty when there's no value in A. Double quotes("") is actually not quite empty for many other things in Google sheets.
Also I modified your header conndition from ROW(A2:A)=2 to ROW(A2:A) = ROW(A2). I find that this is a more flexible condition for the header as it allows you to potentially insert/delete rows above the header without breaking things.
It seems QUERY() may be good choice. Try-
=QUERY(data!A2:E,"select A,B,C, sum(E) where A is not null group by A,B,C",1)
If you need specific month then you can add criteria to where clause like-
=QUERY(data!A2:E,"select A,B,C, sum(E) where A =5 group by A,B,C",1)

Trying to auto-generate SKUs in Google Sheets using prefix and sequence number but it breaks when sheet is sorted

I want to automatically generate unique, incremented ids (SKUs) for products in my inventory using Google Sheets. These SKUs should be immutable and not change when the sheet is sorted. This screenshot shows my flawed attempt to do this:
The formula I have for column A is:
=if($B2<>"",$B2 & TEXT(COUNTIF($B$2:$B2,$B2),"-0000"),"")
That formula appears to give the desired result. However, if I sort by the values in Column C, SKUs become associated with different Item Names, which is a problem. How can I modify the spreadsheet to get immutable, auto-generated SKUs?
Update:
I would like to be able to add additional rows/SKUs to the sheet over
time
Here is a link to the sample spreadsheet
I've added a sheet ("InventoryMaster(Unsorted") to your spreadsheet.
This sheet would be used to add your prefixes and items only. Once added, you would never sort, insert rows, delete rows or items, etc. Just keep adding the next prefix and item into the next open row, in Col B and Col C. Col A has a formula that will create the static SKUs from that unchanging and ordered information. (I've hidden that formula-containing Col A, so that you only have to enter the manual data and don't have to worry about accidentally overwriting the formula or its results. It's still there at all times, serving its purpose in the background.)
Then, other sheets (see my added "Erik Help" sheet) can reference that "immutable" list, giving you the ability to sort without losing SKU connection.
Here is the A1 formula from the 'InventoryMaster(Unsorted)' sheet:
=ArrayFormula({"SKU";IF(B2:B="",,B2:B&TEXT(COUNTIFS(B2:B,B2:B,ROW(B2:B),"<="&ROW(B2:B)),"-0000"))})
And here is the SKU-assigning formula from A1 of the "Erik Help" sheet:
=ArrayFormula({"SKU";IF(B2:B="",,VLOOKUP(B2:B&C2:C,{'InventoryMaster(Unsorted)'!B2:B&'InventoryMaster(Unsorted)'!C2:C,'InventoryMaster(Unsorted)'!A2:A},2,FALSE))})

How can I compare strings and sort them accordingly using an auto-generated Google Forms response sheet?

So my goal is to have every name on the roster in column A and then have the names of those who respond (not everyone will respond) in column B. I want column A to sort alphabetically. I want column B (and the corresponding columns with answers (C-E)) to only fall in line if the name matches. Otherwise columns B through E would be left blank. Any help would be appreciated. Thanks!
Make a new sheet with the roster names. After typing them, use the Google Sheets sorting tools to sort them.
Use the match function to identify the corresponding row in the first sheet for each of the roster names.
Once you have got the row, you can get the data for any cells in that row. See Get content of a cell given the row and column numbers .

How do I import data from another sheet and then filter it based on 2 different variables?

I have been working on how I budget and keep track of my finances. In the process, I put together this Google Sheet which I am happy to share a dummy version of (includes dummy data).
I use a Google Form to input new entries which are recorded in the 'Log' page.
From here, I use a few SUMIFS to pull in the totals of any given income/expense category based on the category name (referenced in the cell adjacent), the month (B3), and the year (C3).
What I now want to do is add a table (currently in columns O:Q) that calls in itemised log records based on the category selected (O2) and the month and the year. On the reference sheet these are cells (B3) and (C3) respectively and in the log, these are columns (F) and (G).
I've gotten as far as using an INDEX / SMALL array formula combination to pull in all spending as per the category selected in (O2), but what I cannot seem to figure out is how to then restrict results to only those that also match the month and year. I've tried using a MATCH formula but am unsure how to append this within the current formula string, if it is even possible?
Once working, this would (for example) mean that only rows 4 and 5 in columns O, P, and Q would be populated as these are the records for the selected month, June 2016.
Is what I want to do possible through a more complex formula? Can anybody help?
Thank you in advance.
Link to my Google Sheet: https://docs.google.com/spreadsheets/d/1_GGgFCfMtB5ROkTmpx4Fn4nZZbBIvBa4vpOwqswH5E0/edit?usp=sharing
The following should do the trick.
Delete everything in O4:Q14
In cell O4, write: =FILTER(Log!H2:H, Log!B2:B=O$2, Log!G2:G=C$3, Log!F2:F=B$3)
In cell P4, write: =FILTER(Log!E2:E, Log!B2:B=O$2, Log!G2:G=C$3, Log!F2:F=B$3)
In cell Q4, write: =FILTER(Log!D2:D, Log!B2:B=O$2, Log!G2:G=C$3, Log!F2:F=B$3)
(By the way, you can generate columns F, G and maybe E from column A in the Logs sheet. For example, just remove the data that is already in column G and in G2 write: =ARRAYFORMULA(YEAR(A2:A))
Link to spreadsheet with fixes:
https://docs.google.com/spreadsheets/d/1iIplXRa28L7FdmqI91RbjApO3g-GU5uk6rTQLqi7vFw/edit#gid=0

How can I filter my search in a column on google sheet which collects data from a form?

I would like to perform a multi criteria search of data in a column- contains data of check boxes(more than one option chosen).
For a clearer picture of what I am trying to do, screenshot below is a question in a form
Data from the form are saved in sheets like below,
So my concern here is if I would like to search/filter for the rows that contain "Commercial", the rows with Commercial,Engineering doesn't show up. That's definitely not an effective search.
Any advise on how can I go about this issue is kindly appreciated. If
Let's say you have your form in the response sheet in columns A to P, with the multiple choice in col D. If you want to filter your data on the word 'Commercial' you can either do:
=filter(A2:P, regexmatch(A2:P, "Commercial"))
or use query():
=query(A2:P, "select * where B contains 'Commercial' ")
Note: depending on your locale you may have to change the commas to semi-colons in order for the formulas to work.
I hope that helps ?
Following JPV's answer, I developed a line to make the query useful if you want to cross two categories. Let's suppose that someone in your checkbox example had picked all the options (IT, HR, Commercial, Engineering); and that you have created the cell with the dropdown option box in cell B1 with all your options, as JPV said.
Then, you want to filter and see all the people who had chosen IT and Commercial. You would, for that, create a second cell with the dropdown option box in, lets say C1; and then your query would be:
=query(A2:P, "select * where B contains '"&B1&"' and B contains '"&C1&"' ")
=FILTER(MOBILE!A2:E2000, ISNUMBER(SEARCH(A1,MOBILE!A2:A2000)))
SEARCH function will return a number of the position of the searched word (A1) in the searched strings in range (MOBILE!A2:A2000).
If the result of search is a number (ISNUMBER), then filter will return the TRUE rows result from the range MOBILE!A2:E2000.

Resources