calculate value string that is in a list - google-sheets

Data:
Row A
House;Farm;Zoo
House;Farm
House, Zoo
Row B
Dog;Cat;Lamb;Tiger
Dog;Bunny;Chicken,Fish
Lizard;Cat;Cow
Table 1
House
Dog
Cat
Mouse
Fish
Chicken
Table 2
Zoo
Tiger
Bear
Seal
Table 3
Farm
Bunny
Duck
Lamb
Cow
Horse
Question In Google Sheets
Ok I am trying to figure out how to calc the Column A based on what string is in the Column B The definition of what is in the B Column comes form the three tables in the bottom. Any help would be wonderful!

So here is one way. In some other region of the table, from which you will copy column A at the end, set up the following expression for each row, starting in column B. I am imagining your =original list with column A to be calculated starts in row 1 (so B1 is dog, C1 is cat, and so on).
Suppose your 3 tables sit in rows 6 to 8.
Some rows below, in column A, paste the following:
=IF(ISBLANK(B1),"",IFERROR(QUERY($A$6:$F$8,"Select A where "&"(B = '"&B1&"') OR " & "(C= '"&B1&"') OR "& "(D= '"&B1&"') OR "& "(E= '"&B1&"') OR (F='"&B1&"')")))
Let me unpack that. If the entry is blank, we will leave the corresponding item empty. Similarly, if our query fails, leave it blank. But the query says look in the tables, find the match, and give us the corresponding column A value.
Drag this formula right 3 more columns for a total of 4, which is the longest length of animal list we're trying to cover. You end up with the corresponding places (if any), cell by cell. Also drag this formula down 2 more columns so you get each row.
Clinch by doing the following one column further over. I was in row 10, your row may vary.:
=textjoin(";",true,transpose(unique(transpose(A10:D10))))
this puts togethjer a list of the unique, noempty, values, separated by semicolons.
Drag this down 2 columns, and then go back let you A1=the top corresponding entry, drag down, and you're set.
EDIT: The above assumes Dog, Cat, Lamb, and Tiger are spread across cells in columns B, C, D, and E. If not and they are in just one cell, you may need something like in the C column =split(B1,";") and to adjust columns in my formulas over by 1.

Related

Google Sheets - get value from above

I'm trying to work out a function in a Google Sheets cells to look at a column then search current row and "above" the current row to find a non number value (text).
I have data that in two columns B (item code or category) & C (item description).
I need another column to contain the categories for each item - column D. I'm looking for a formula for this column, ideally an Arrayformula as the data can change, there can be multiple items per category, some might be only 1 item, some might be 100 items per category. The arrayformula in column D will get the category from column B if it is not a number.
B column - categories and item codes, C column - item descriptions, target is D column a copy of the categories from column B.
I've tried this numerous times and usually give up, do it manually but it becomes teadious quickly. Looking forward to any help that might come from this! thanks.
In D2 try
=Arrayformula(if(isnumber(B2:B), vlookup(row(B2:B), filter({row(B2:B) , B2:B}, istext(B2:B)), 2), B2:B))
and see if that works?
Try in D1
={"Category";ArrayFormula(lookup(row(B2:B),row(B2:B)/if(isnumber(B2:B),0,1),B2:B))}

I am trying to filter out and match exact text in Google Sheets

I have text in a Google Spreadsheet that is the result of a query.
In cell A2, I have a student's name.
In cell B2, I have a list of all of their courses.
For example, B2 may look like:
English I
Math I
World History
PE
Photography 1
(one course per line, all in the same cell)
In column E, I have a list of the courses.
In column F, I need a list of all of the students that have that course in Column B. I need each list to be in one cell.
For example in E2, it would say English I. And in F2, it would read:
Student 1
Student 2
Student 3
(one cell, one student per line)
With this formula, I get a list of all students that have that course, but also any where it contains that course.
=IFERROR(if(E2="","",(JOIN( char(10) , FILTER(A:A,search(E2,B:B))))))
So, it returns all the students taking English I, but also all the ones taking English II.
Is there anyway to make it exactly match English I and only English I?
https://docs.google.com/spreadsheets/d/1l53sEQHc6SqZW-3ycYVkGtTKaj3ZCJFRk4NXlMQR4xE/edit?usp=sharing. I need it to be formatted like the yellow column on the 'All Recs by Course' Tab.
Edit:
If I pull it in from a different sheet using this formula:
=IFERROR(if(E2="","",(JOIN(char(10),(FILTER(FEED!X:X,search(E2,FEED!V:V)))))))
I seem to be able to pull the right courses, but instead of the cell looking like:
Student 1
Student 2
Student 3
(one cell, one student per line)
It looks like:
Student 1, Student 2, Student 3
(all students in a horizontal list in a single cell - which is how it is on that original sheet).
Thanks in advance,
Beth
in H2
=sort(unique(arrayformula(flatten(split(B2:B7,char(10))))))
in I2 (drag to the next cells below)
=textjoin(char(10),,query(arrayformula(split(flatten(split(B$2:B,char(10))&"~"&A$2:A),"~")),"select Col2 where Col1='"&H2&"' "))

Lookup a value in Column B or C and return key in Column A

I am trying to write a formula that will look for a value in a column, and return the first cell in the row in which it finds the value. So a little like VLOOKUP, but I don't want to search the the first column.
Here is an example dataset:
Room
Monday
Tuesday
DWG 1
S01
S02
DWG 2
S02
S04
DWG 3
S03
S06
DWG 4
S04
S07
Here is what I would like to generate using a formula.
So for the value at B2, I would like it to look up A2 ("S01") in the B column ("Monday") of the top table, and return the value of the cell in the 1st column ("DWG 1").
Ideally it would return nothing or a blank if it doesn't find the exact string in the top table.
Section
Monday
Tuesday
S01
DWG 1
S02
DWG 2
DWG 1
S03
DWG 3
S04
DWG 4
DWG 2
S05
S06
DWG 3
s07
DWG 4
After seeing your in-sheet data and layout, and meeting up with you there live, this is the formula I left for you in the newly added sheet "Erik Help":
=ArrayFormula({"S"&TEXT(SEQUENCE(24,1),"00"),IFERROR(VLOOKUP(FILTER(B1:1,B1:1<>"")&"S"&TEXT(SEQUENCE(24,1),"00"),SPLIT(FLATTEN(FILTER(Sheet1!B1:1,Sheet1!B1:1<>"")&FILTER(INDIRECT("Sheet1!B3:"&ROWS(Sheet1!A:A)),Sheet1!B1:1<>"")&"|"&FILTER(Sheet1!$A3:$A,Sheet1!$A3:$A<>"")),"|"),2,FALSE))})
For the understanding of others, the days of the week (i.e., Monday, Tuesday...) are entered manually as top headers in B1:F1. The header "Section" is entered in A2 with B2:F2 blank. (This is just how the OP wanted it set up.) And the formula is in A3, processing data for A3:F.
The first part of the virtual array just generates the SEQUENCE of section names (S01 - S24) in A3:A26.
The next part looks up every element of one array within another array. The first array is a concatenation of every weekday with every section number from Column A. The second array didn't technically need to be as long as it is in the formula, because we already know exactly how many weekdays, classrooms and sections there are. But it is written to accommodate flexibility, perhaps for future use where four or six days are required, with more or fewer sections.
That second array concatenates every weekday with every section from Sheet1 followed by a pipe symbol and the room for each row from Sheet1. That grid is FLATTENed to one column, and then SPLIT to two columns at the pipe symbol.
Found elements, then, return the class name (which was SPLIT to Column 2 of the virtual VLOOKUP array). If there is no match, IFERROR returns null.
The shorter version possible since we know exactly how many days, sections and rooms we have (and which I left in a new sheet called "Erik Help 2") is this:
=ArrayFormula({"S"&TEXT(SEQUENCE(24,1),"00"),IFERROR(VLOOKUP(Sheet1!B1:F1&"S"&TEXT(SEQUENCE(24,1),"00"),SPLIT(FLATTEN(Sheet1!B1:F1&Sheet1!B3:F17&"|"&Sheet1!A3:A17),"|"),2,FALSE))})
The function you're looking for doesn't exist in Sheets as Vlookup match is performed horizontally from left to right. However, a workaround is to rearrange the columns within the function QUERY and perform a Vlookup to it
Here's an example formula you can use =iferror((vlookup("S01",QUERY(A2:C, "Select B,A",0),2)),"")
This will also leave the cell blank if there are no matching results.
Here's an example of what the end result would look like when I the string "S01" is Vlooked up:

On Google Sheets, how do I 'attach' the value of a cell to the value of the cell on the left?

I have a table with 3 columns, say A, B and C, though only column C is editable by the user.
Column A contains values all from another sheet - the number of values in this column can change as values are deleted or added to the other sheet (EDIT: new values can be added to any part of the other sheet, not just the bottom).
Column B is a uniquely sorted list of the values of Column A.
Column C is currently just a normal column that takes values from the user.
When a user enters a value in a Column C cell, they do so based on the cell to the left (in column B). However, as the values in the other sheet can change, values in column B can be deleted or move up or down a row, or new values can appear anywhere in this column B.
Somehow, when the user puts "bar" into a cell in column C on row X and the value of column B on row X is "foo", then rather than "bar" always just staying in cell CX: 1) when "foo" changes it's row to row Y (because another value has been added to or removed from column B, or the first letters of the value in BX have been changed), "bar" should also move to row Y 2) if "foo" is completely removed from column B, "bar" should also be removed from column C 3) new values in column B should have blank column C cells to the right of them.
Eg say the table looks like this
B: C:
apple Rsdne fwe
banana Fg fdsg gse
grape Awtoi fje
lime Wpe fjweo
orange Jbob
If on the other sheet: a new value "kiwi" is added, "orange" is changed to "clementine" and "bananas" is removed, after all this the table should then look like this:
B: C:
apple Rsdne fwe
clementine Jbob
grape Awtoi fje
kiwi
lime Wpe fjweo
Is this / any of this possible? If so, how is this done?
Data entry should happen in a fixed table and not into a moving structure. Changing the association of a data entry row to a different parameter is simply bad data architecture. There isn't a simple formula solution to counter that.
My advice is to step back and determine what you want to achieve, then design a process that is fit for that purpose.
Creating a unique list of values from a hidden column is a reporting technique. Then this report is getting mixed with data entry. These two things, i.e. data entry and reporting should never happen on the same sheet.
Create a sheet that has all the possible unique values in a constant data entry table. Let the user enter their values into that DataEntry Table. New values can be added to the bottom of the table. If Orange is changed to Clementine, don't delete the row for Orange, just leave it and add a new row for Clementine.
Then you can create a report that takes the duplicates from your initial first sheet, creates a list of unique values and then uses lookups formulas to pull the user entries from the DataEntry table.

Formula to Test for Blanks in two Columns Against a Third Column

So I am using a conditional formatting custom formula to highlight a cell if the column it is summing from another spreadsheet has blanks, but I don't know how to do it with changing ranges. Basically what I want to do is use a third column, say column A, to determine the length of the range (of rows) I want to scan with CountBlank, and if it picks up a blank in there to return a "True".
So basically:
Column A Column B Column C Column D
Person 1 5:30AM 3:00PM 9.5
Person 2 5:00AM 8
Person 3 4:30AM 4:00PM 10.5
So ideally, the cell sums the fourth column with a different function (already have that), and it conditionally formats itself if a blank is picked up in Columns B or C, going all the way down to the last row of column A that has a value. Any help here would be appreciated, thank you.
If I understand you correctly, the custom formula for conditional formatting should be:
=or(countifs(A2:A,"<>",B2:B,""),countifs(A2:A,"<>",C2:C,""))
Suppose you had a list of people's names starting in F2 and their total hours starting in G2. Then you could alter the formula to:
=or(countifs(A$2:A,F2,B$2:B,""),countifs(A$2:A,F2,C$2:C,""))

Resources