Is there a function in Google Sheets to return the string next to a string that I match from a column of strings? - google-sheets

Okay, Sheet1!F:F is a list of words in English. The same word occurs multiple times and the sheet is organized in order of chapters with the words in question in order as they appear in the chapter. "G:G needs to be that word in Arabic. "H:H needs to be the definition in English. "I:I needs to be the definition in Arabic.
Sheet2!A:A has the word in English, B:B the word in Arabic, C:C the definition in English, D:D the definition in Arabic.
Is there a function that would allow me to find the word from Sheet1!F:F in Sheet2!A:A and return Sheet2!B:B in Sheet1!G:G?
Here's some snipits of an example sheet.
Sheet1!
Sheet2!

You want to find the "Word AR" Sheet1 column G in "Word AR" Sheet2 column B, in other word find the arabic word for the English word from another table.
Paste this formula in Sheet1 cell G2, and drag it down.
=IF(F2="",,INDEX(Sheet2!$B$2:$B,IFNA(MATCH(F2,Sheet2!$A$2:$A,0),"No Match")))
Breakdown:
1 - MATCH function to find the matching row in the range Sheet2!$A$2:$A with [search_type] set to 0 to finds the exact value when range is unsorted.
2 - INDEX gives back a cell's content from a range when given a row and column, our reference is Sheet2!$B$2:$B we set the [column] as 1 or left it blank in case of a single column and pass the result of MATCH function as [row].
3 - handel N/A error with IFNA function and set [value_if_na_error] to "No Match".
4 - IF function IF(F2="",,[value_if_false] To calculate only when the cells of F columns are not blank.
hope that answers your question.

One option would be to use a VLOOKUP formula. For example:
=ifna(arrayformula(vlookup(A2:A, Sheet2!A2:D, 2,0)))
Sheet1:
Sheet2:
This formula can be adjusted to fit your needs:
=ifna(arrayformula(vlookup(F3:F, Sheet2!A2:D, 2,0)))
This can be placed in cell G3 of your Sheet1 and it will auto fill down the column. Repeat this for the next 3 columns, and simply increment from 2 in the original (ie =ifna(arrayformula(vlookup(F3:F, Sheet2!A2:D, 3,0))), etc)

Related

Google Sheet ISBETWEEN doesn't recognize named range?

Column A is named "Quantity", which works in a simple formula:
I'm getting an error when attempting to use a named range in ISBETWEEN formula:
I verified that ISBETWEEN works when I use cell reference A2 instead of named range Quantity:
Any thoughts how I can fix? 😤
Your named range Quantity has its range set to A1:A but you are entering it in row 2, so error says there is no room in A2:A for A1:A unless you add a row but when you do it's the same coz you can't fit 3 keys into 2 keyholes (from one side each of course)
As seen on this sample:
See my comment to your original post.
Assuming that your named range Quantity is applied to the entire range A:A (and not A2:A), delete everything from Col B (including the header) and then place the following formula in cell B1:
=ArrayFormula( {"Test"; IF(A2:A="",, ISBETWEEN( FILTER(Quantity, ROW(Quantity)>1), 1, 5) ) } )
This one formula will create the header text (which you can change within the formula if you like) and all results for all valid, non-null rows.
FILTER(Quantity, ROW(Quantity)>1) is necessary to limit the full range of the named range Quantity to only those elements whose row is greater than (row) 1; this is because your results begin in Row 2.
You only need this one formula. As you add more data into Col A, the formula will process it.

Compiling a list using INDEX but need to skip certain rows

I'm compiling a list based on the first answers recieved between row N and AF.
I'm using these two formulas:
=INDEX(N2:O2,MATCH(FALSE,ISBLANK(N2:O2),0))
and
=INDEX(R2:AF2,MATCH(FALSE,ISBLANK(R2:AF2),0))
Is there a way to combine them whilst not searching in rows P & Q?
These are generated from a Form response so can't just be switched around.
try:
=INDEX({N2:O2, R2:AF2}, MATCH(FALSE, ISBLANK({N2:O2, R2:AF2}), 0))
If Sheet1 is an intake sheet of form results, you should not add any data, formulas or even formatting to that sheet. It virtually always causes issues. A form intake sheet should be left exactly as it is. A new sheet can then be used to bring over the results of the form intake sheet as you want to see them.
However, since you didn't specify any of that, I will supply a formula written to work in the same sheet as your posted example and in-sheet examples.
Clear an entire column and place the following in the top cell of that column:
=ArrayFormula({"Attendee Name"; IF(E2:E="",,IFERROR(REGEXEXTRACT(TRIM(TRANSPOSE(QUERY(TRANSPOSE(FILTER(IF(N2:AK="",,N2:AK&"~"),N1:AK1=N1)),,COLUMNS(N1:AK1)))),"\s*([^~]+)"),"(none listed)"))})
This one formula will produce a header (the text of which you can change within the formula itself as you lie) and all valid results for all rows.
The inner IF will append a tilde (~) to any non-null entries in the range N2:AK.
FILTER will keep only those columns in this range where the header is the same as the header in N1 (i.e., "Attendee Name").
TRANSPOSE(QUERY(TRANSPOSE( ),,COLUMNS( ))) is colloquially called a "Query smash." It will form one cell from all horizontal results per row.
TRIM will cut any preliminary spaces and form a true string.
REGEXEXTRACT will pull the from the first non-space character up to but not including the first tilde (from those appended in the first step)—in other words, the first full valid entry from any column.
IFERROR will return a message if there is an error, with the likely error being that there were no valid entries for "Attendee name" in any column.
The outer IF will leave the cell blank if the no training event exists in E2:E.
{ } forms a virtual array that places the header over all other results.
ArrayFormula( ) signifies that multiple results will be processed at once.
Because this is an array formula that is being "asked" to process every row, you cannot manually type into any cell of this results column. If you do, you will "break the array"; everything except what you just typed will disappear, leaving only an error in the formula cell. If you need to add or change a name, you need to do that in the raw results range (e.g., manually type a name or a new name in Col N), which will then turn up in the formula output range.

How can I search for a substring in a cell, using several cells as the search argument? [Google Sheets]

In Google Sheets,
I'm trying to indicate whether each cell in a specific column (Let's call it "Target column") contains any of the words listed in a group of cells (Let's call it "Word warehouse").
The idea is that each cell in Target column that isn't empty AND doesn't contain any word from Word warehouse will add +1 to some other cell in the spreadsheet.
For example, if my column contains any of {"No", "Not", "None", "Negative"} then I will ignore it. If it contains anything else (and is not empty) then it will be counted.
Using Search or Vlookup doesn't help since they expect a single string value rather than a range of cells (Word warehouse).
You can try following formula:
=--ArrayFormula((SUM((--ISNUMBER(SEARCH(TRANSPOSE($D$1:$D$4),A1))))=0)*(A1<>""))
In example range A1:A7 is Target column and range D1:D4 is Word warehouse.
I may have an answer that works for you. See my sample sheet here.
The key formula, C2 in the sample sheet, is:
=QUERY(A2:B,"SELECT A WHERE UPPER(A) MATCHES '" &
UPPER(".*" & JOIN(".*|.*",FILTER(B2:B,B2:B<>"")) & ".*") &
"' ",0)
where A2:A is your "target column" and B2:B is your "word warehouse".
This tests each word or phrase in column A against the (filtered) list of words (or phrases) in column B, and produces a list of all of the ones that match.
By counting the total number of entries in column A, and subtracting the count of the number that matched, you get a count of all of the ones that didn't match. This can be done with this formula - D2 in my sample sheet:
=COUNTA(A2:A) -
COUNTA(QUERY(A2:B,"SELECT A WHERE UPPER(A) MATCHES '" &
UPPER(".*" & JOIN(".*|.*",FILTER(B2:B,B2:B<>"")) & ".*") &
"' ",0))
Note that I've made the match insensitive to case. This can easily be removed, by removing the upper function in the two places in the formula. This also matches on partial matches, eg "Catcher" matches "cat" in the word warehouse. This could also be easily changed.
I also only count one match per phrase, even if it contains several of the words in the warehouse.
Let me know if this helps.

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,""))

Sum values based on row value and column header

We have a Google Sheet doc which contains a date column with each date as a row value, and also multiple columns (some of which have the same name) and we want to sum the values in the cells where the row is a specific date, and the column has a specific header. For example where the date is 01/03/2017 we want to sum all the values which have the column header "X" on that date. Can this be done?
Yes it can be done
=SUMIF($C$3:$J$3,"X",OFFSET(C3:J3,MATCH(B1,B4:B15,0)+3,0))
Broken down
=sumif($C$3:$J$3 [<-header row with X],"X" [<-what we're looking for],C3:J3 [<-row to sum])
the formula above will sum the header row if there is an "X" (not very useful)
I used offset(C3:J3,[row number],0) with the header row range to push it down to the row matching 01/03/2017
To get the row number of 01/03/2017 I used Match() and put 01/02/2017 in cell B1
MATCH(B1,B4:B15 [range of dates] ,0)
I add 3 becuase my range starts at 4
You can hard code the date into the formula by replacing B1 with
DATEVALUE("01/03/2017")
I've not tried this in Google Sheets as I don't have access at the moment but it works in Excel and I'll try it in Sheets later.
Here's the formula that you can paste into A2 on your sheet "Sum of Data"
=SUMIF(Data!$B$1:$J$1,B$1,OFFSET(Data!$B$1:$J$1,MATCH($A2,Data!$A$2:$A,0),0))
It's all about changing the original formula to match your data and also locking the ranges correctly with the $ so that it will autofill down and across without breaking.
Use INDEX to peel off the appropriate column for SUMIF.
=SUMIF(A:A, G4, INDEX(A:E, 0, MATCH(H4, 1:1, 0)))
Considering a sheet where:
Cell B1 contains the date of interest (e.g. 01/03/2017)
Cell B2 contains the header of interest (e.g. X)
Cell B3 returns the sum of interest (values of all columns with header "X" on 01/03/2017)
Row 4 contains the headers to be evaluated (e.g. "Date", "A", "B", "X", "C", "X", "D")
Subsequent rows contain the actual data (e.g. dates in column A and data in columns B:G)
Refer to the image on the link below for details:
Example with cells of interest highlighted in yellow
The following formula should return the expected result:
=SUMIF(4:4,B2,INDEX(A:G,MATCH(B1,A:A,0),0))
I used Google Sheets in Portuguese. So, the formula actually tested was:
=SOMASE(4:4;B2;ÍNDICE(A:G;CORRESP(B1;A:A;0);0))
I hope that was usefeul.

Resources