All IFS are from the same range CO4:CO53, changing only the value to be searched, considering that there is only one range to search, is there any way to simplify it so that it doesn't get so big?
It is noteworthy that all must be changed to the same value if found.
=ARRAYFORMULA(
IFERROR(
IFS(
CO4:CO53="Out","",
CO4:CO53="Mid","",
CO4:CO53="Early","",
CO4:CO53="Late","",
CO4:CO53="Red","",
CO4:CO53="Yellow","",
CO4:CO53="1","",
CO4:CO53="2","",
CO4:CO53="3","",
CO4:CO53="Disciplinary","",
CO4:CO53=1,"",
CO4:CO53=2,"",
CO4:CO53=3,""
),
'Copy of Top Plantel A'!A2:A51
)
)
See my comment attached to the original post.
However, given only what I can see, you can try this method:
=ArrayFormula(IF(REGEXMATCH(CO4:CO53&"","^(Out|Mid|Early|Late|Red|Yellow|1|2|3|Disciplinary)$"),,'Copy of Top Plantel A'!A2:A51))
REGEXMATCH returns TRUE (if a match is found) or FALSE if not.
The pipe symbol acts as OR.
A space is appended to CO4:CO53 to convert the numbers 1, 2, 3 to strings (necessary for use with REGEX-type functions).
If the formula as written does not work as expected, please do share a link to the spreadsheet (or a copy of it), with permissions set to "Anyone with the link..." and "Editor."
Related
A user pastes in a value to see if there is a full or partial match. I need to do a vlookup and keep removing characters until there is a match. A full match of something like test1.test2.test3 is no problem because it's a full match to my list. But if someone pastes in something like test1.test2.test3.test4, I need to remove a character one at a time from the end until there is a match. So in this example, it would match test1.test2.test3 and return that result.
Conceptually I see this as a for loop that counts the characters using len, using left to remove the number of characters from the end based on the current iteration, and doing vlookups until returning the value when true. But I'm not sure how to do this in Google Sheets.
This formula will give you the matching value that was found in the data(i.e. test1.test2.test3)
=FILTER([column_with_data], REGEXMATCH([cell_with_pasted_value_to_look], [column_with_data]))
This formula will give you the matching data and the cell reference where it was found (i.e. test1.test2.test3 # $A$4)
=FILTER([column_with_data], REGEXMATCH([cell_with_pasted_value_to_look], [column_with_data]))&" # "&CELL("address",INDEX([column_with_data],MATCH(FILTER([column_with_data], REGEXMATCH([cell_with_pasted_value_to_look], [column_with_data])),[column_with_data],0),1))
Simply copy & paste any of the above formulas next to the cell where users paste a value to look. Then, replace the two references in the square brackets [ ] with the proper coordinates in your sheet:
replace [column_with_data] with the coordinates of the column containing all the stored data (i.e. A1:A)
replace [cell_with_pasted_value_to_look] with the absolute ($col$row)coordinates of the cell where users paste the value to look (i.e. $B$1)
Would it be a problem to download the data from Google sheets, transform the file type to use the for loop in another software, and re-upload? I think your idea for a for loop would work.
It might be quicker if this is a long term project, but not so great if the client is continually monitoring/uploading.
I'm using Coingecko to get cryptocurrency prices, and update the data using a 1 hourly Trigger. As the IMPORTDATA function often fails (a known issue using Coingecko), I have a second Trigger than copies this data as a 'backup', using CopyPasteType.PASTE_VALUES.
The primary data is Named Range 'Crypto_Data', the backup is 'Crypto_DataBackup', and the cell's formula is:
=iferror( vlookup(F24,"Crypto_Data",2,false), vlookup(F24,"Crypto_DataBackup",2,false) )
However, the vlookup to "Crypto_DataBackup" fails as it "evaluates to an out of bound range". It works AOK if I just substitute the range of the Named Range (CryptoData!M3:W502).
Does anyone have an idea what the problem could be?
but if you like quotation marks use:
=IFERROR(VLOOKUP(F24, INDIRECT("Crypto_Data"), 2, ),
VLOOKUP(F24, INDIRECT("Crypto_DataBackup"), 2, ))
also, why not:
=IFNA(VLOOKUP(F24, {Crypto_Data; Crypto_DataBackup}, 2, ))
As #Sergey pointed out: "The named range does not need to be enclosed in quotation marks. Change your formula like this: vlookup(F24,Crypto_Data,2,false)"
-- EDIT #2 -- Updated the Google Sheet again with a solution which is painfully close. Best formula I've had so far is below. --
=ARRAYFORMULA(SPLIT(UNIQUE({ARRAYFORMULA(QUERY(IF(COUNTIF(G4:G&"|||"&H4:H,ARRAYFORMULA(A4:A&"|||"&B4:B))>0,REGEXREPLACE(A4:A&"|||"&B4:B,".*",""),A4:A&"|||"&B4:B),"SELECT * WHERE Col1 IS NOT NULL"));ARRAYFORMULA(QUERY(IF(COUNTIF(G4:G&"|||"&H4:H,ARRAYFORMULA(D4:D&"|||"&E4:E))>0,REGEXREPLACE(D4:D&"|||"&E4:E,".*",""),D4:D&"|||"&E4:E),"SELECT * WHERE Col1 IS NOT NULL"))}),"|||"))
-- EDIT -- Updated the Google Sheet to more closely reflect my use case --
Pretty confident someone's asked this before but I've been Googling for a few hours now and I'm starting to lose hair. I think I've got to use a QUERY function but not 100% on that.
Demo sheet here: https://docs.google.com/spreadsheets/d/1p_hqk9WydcyXQZT4bIm4DSZZnaPKbngtnZ0-laYHwk8/edit?usp=sharing
What I want to do:
I want to combine the ranges under DATA 1 and DATA 2, but I want to exclude and rows which start with the values in DATA 3.
RESULT 1 doesn't add value but shows how I was adding DATA 1 and DATA 2 together.
RESULT 2 shows the result I'm trying to get.
RESULT 3 hidden but where I got to (and doesn't add value again, sorry). I can get it mostly working, but I'd have to manually specify in the QUERY which combinations I'm looking for... and frankly my dataset is HUGE. That formula currently looks like this:
=QUERY(UNIQUE({FILTER(A4:B,NOT(ISBLANK(A4:A)));FILTER(D4:E,NOT(ISBLANK(D4:D)))}),"SELECT * WHERE NOT Col1 STARTS WITH 'a' OR NOT Col2 STARTS WITH 'v'",-1)
Hope someone can help me out! You're my only hope.
This works for your example data. It uses ARRAYFORMULA and MATCH to concatenate the two columns and LEFT to only use the first character in the match function. You might need to find a slightly smarter way to do the starts with element depending on your actual data.
=UNIQUE({FILTER(A4:B,not(isblank(A4:A)),iserror(MATCH(ARRAYFORMULA(A4:A&left(B4:B,1)),ARRAYFORMULA(G4:G&H4:H),0)));FILTER(D4:E,not(isblank(D4:D)),iserror(MATCH(ARRAYFORMULA(D4:D&left(E4:E,1)),ARRAYFORMULA(G4:G&H4:H),0)))})
Documentation:
MATCH: here
ARRAYFORMULA: here
Was also looking for how to find the set-difference between two ranges.
All my values were in one range but I reworked my solution to fit your case of needing to join ranges too.
Finding the set-difference between two ranges:
// given A1:A9 and C1:C9
// return all values in A1:A10 excluding those in C1:C10
=filter(A1:A9, not(iferror( match(A1:A9,C1:C9,0), false )), A1:A9<>"")
Finding the set-difference between two joined ranges and a third range:
// given A1:A9, B1:B9, and C1:C9
// return all values in A1:A10 and B1:B10 excluding those in C1:C10
=filter({A1:A9;B1:B9}, not(iferror( match({A1:A9;B1:B9},C1:C9,0), false )), {A1:A9;B1:B9}<>"")
Breakdown:
Goal is to get an output range that is the input range excluding all values in an "exclusion" range
MATCH: match all values that are in both your input range and your exclusion range (remaining values will produce an error)
NOT + IFERROR : convert matches to false and errors to true
FILTER: filter the input down to only the true values (i.e. whats not matched, a.k.a. remove the excluded values), and also add a 2nd condition to remove blanks
tips:
{X;Y}: unions two ranges, ; adds rows , adds columns
X<>"": true for all non-blank values in range X
My table contains 2 sheets with a different number of columns. I want to add a column that will display true or false (or any other 2 opposite values ) for each row depending on whether this row satisfies 2 criteria which are: sheet1!col1=sheet2!col1 and sheet1!col2=sheet2!col2.
You'll find an illustration below.
I've tried using
ARRAYFORMULA(VLOOKUP(A1&B1, {Sheet1!A1:A4&Sheet1!B1:B4,Sheet1!C1}, 3))
but I get an error message
vlookup evaluates to an out of bound range
So I wanted to try
QUERY({Sheet1!A1:B4,A1:B5}, "Select C where ")
but I couldn't figure out how to write the condition where (sheet1)col1=(sheet2)col1 & (sheet1)col2=(sheet2)col2 and I also don't know if I can work with tables of different dimensions. I finally tried
=MATCH(A1&B1,{Sheet1!A1:A&Sheet1!B1:B})
but it always returns 1.
Any idea please?
Sheet 1
Sheet 2
Your first formula is almost right. You are getting the error message because there is only one column in the curly brackets so you have to change it to
=ArrayFormula(vlookup(A1&B1,{Sheet2!A:A&Sheet2!B:B},1,false))
and add the 'false' to make sure it only does exact matches.
To make the query work you need the right syntax to access cells in the current sheet:
=query(Sheet2!A:B," select A,B where A='"&A1&"' and B='"&B1&"'")
To make the match work, you need to enter it as an array formula and add a zero to specify exact match:
=ArrayFormula(MATCH(A1&B1,{Sheet2!A:A&Sheet2!B:B},0))
However I would take flak from my colleagues if I didn't point out that there is an issue with the vlookup and match as shown above - toto&moto would match with not just toto&moto, but also with tot&omoto etc. The way round this is to add a separator character e.g.
=ArrayFormula(vlookup(A1&"|"&B1,{Sheet2!A:A&"|"&Sheet2!B:B},1,false))
=ArrayFormula(MATCH(A1&"|"&B1,{Sheet2!A:A&"|"&Sheet2!B:B},0))
These still need some tidying up if they are to report Yes and No, and also not to give false positive on blank rows - also the vlookup and match can be written as self-expanding array formulas - but that is the short answer to the question.
My problem, generally stated:
I need a formula that returns all the values in a specific column for which multiple criteria in other columns of the respective row apply.
My problem, specifically stated:
I would like a formula that returns all the values in Column A for which Column C is "John", Column E is "Apples", Column G is "Earth" and both Columns H and I are empty. See here for a simplified illustration of my problem with dummy data. The correct formula, dragged down, would output a list with the values "1", "4", and "14". If you'd like to try out some stuff in the linked spreadsheet, feel free to do so in a copy of the original sheet so others can see my original data/formulas.
What I've tried so far:
Simply filtering was not an option because the data is on a separate sheet within the same spreadsheet. I also knew VLOOKUP and INDEX/MATCH were not going to do what I wanted - VLOOKUP doesn't handle multiple criteria, and while the MATCH part of INDEX/MATCH can be turned into an array to specify multiple criteria, it only returns the first value for which all conditions are true, while I need all of them.
I then tried the following formula (Formula 1 in the linked spreadsheet):
=IFERROR(INDEX($A$2:$I, SMALL(IF(COUNTIF($K$2, $C$2:$C)*COUNTIF($K$3, $E$2:$E)*COUNTIF($K$4, $G$2:$G), ROW($A$2:$I)-MIN(ROW($A$2:$I))+1), ROW(A1)), COLUMN(A1)),"")
It worked like a charm, until I wanted to include the condition that both columns H and I should be empty. I tried this, but for some reason I don't understand it didn't work (Formula 2 in the linked spreadsheet):
=IFERROR(INDEX($A$2:$I, SMALL(IF(COUNTIF($K$2, $C$2:$C)*COUNTIF($K$3, $E$2:$E)*COUNTIF($K$4, $G$2:$G)*COUNTIF($K$5, $H$2:$H)*COUNTIF($K$6, $I$2:$I), ROW($A$2:$I)-MIN(ROW($A$2:$I))+1), ROW(A1)), COLUMN(A1)),"")
Then I tried to nest my first formula into an IF/VLOOKUP (Formula 3 in the linked spreadsheet):
=IFERROR(IF(VLOOKUP(INDEX($A$2:$I, SMALL(IF(COUNTIF($K$2, $C$2:$C)*COUNTIF($K$3, $E$2:$E)*COUNTIF($K$4, $G$2:$G), ROW($A$2:$I)-MIN(ROW($A$2:$I))+1), ROW(A1)), COLUMN(A1)),$A$2:I,8,FALSE)<>"","",INDEX($A$2:$I, SMALL(IF(COUNTIF($K$2, $C$2:$C)*COUNTIF($K$3, $E$2:$E)*COUNTIF($K$4, $G$2:$G), ROW($A$2:$I)-MIN(ROW($A$2:$I))+1), ROW(A1)), COLUMN(A1))),"")
This worked if I only asked for column H to be empty, but a) it is very unwieldy, b) it gives you blanks in the list it returns, which I do not want, and c) I could not get it to work for the condition that both columns H and I need to be empty using OR.
That's where I'm stuck, and I haven't come up with a good solution. Knowing this forum, I'm sure someone has an elegant solution I was not smart enough to find :)
I'm on phone so formating will suffer.
Create a new column on the left and insert the following into cell A2
=if(D2="John", if(F2="Apples", if(H2="Earth", if(I2="", if(J2="", B2,""), "" ), "" ), "" ), "")