Else statement inside Google Sheets IFS statement - google-sheets

I've got an IFS statement in a column header to calculate some numbers based on a Google Forms input.
I would like to modify one of these column headers to include a check against a boolean and output the results based on this, I'm not sure how to include an ELSE statement inside the IFS statement.
Here is the current code:
=ArrayFormula(
IFS(
ROW(A:A)=1, "NET",
LEN(A:A)=0, IFERROR(1/0),
LEN(A:A)>0, F:F-E:E
)
)
I would like to modify this to include a boolean check before LEN(A:A)>0, F:F-E:E
so: (D:D)=TRUE, B:B ELSE LEN(A:A)>0, F:F-E:E
Hope someone can help! Thanks in advance

In IFS, you can simulate an ELSE using the TRUE condition as the last condition, because the first TRUE result returns the given value - something like: IFS(<condition 1>, <answer 1>, <condition 2>, <answer 2>, TRUE, <default answer>)
But to have an "else if", it's just one more condition of the IFS.
I suppose you mean: IF ROW(A:A)=1 ... ELSE IF LEN(A:A)=0 ... ELSE IF (D:D)=TRUE ... ELSE IF LEN(A:A)>0 ...
Hence, try this:
=ArrayFormula(
IFS(
ROW(A:A)=1, "NET",
LEN(A:A)=0, IFERROR(1/0),
(D:D)=TRUE, B:B,
LEN(A:A)>0, F:F-E:E
)
)

use in row 1:
={"NET"; INDEX(IF(A2:A="",,IF(D2:D=TRUE, B2:B, F2:F-E2:E)))}

Related

Google Sheet multiple matches in uneven data structure

I got this "table" (page raids) and want to do function formating for highlight duplicates (yellow).
Google Sheet
In this case there is match in 2 strings (dark blue):
Name1
Gunslinger
I already try functions VLOOKUP, Match, Filter, countifs and Quary (dont know how it works...) with Index function, but nothing seems work as I want ...
VLOOKUP and Match only gives first value.
Filter doesnt work on this strucker or I dont know how to use it in this case (I know how it works in normal table)
Can someone tell me what function conbination to use that can be put in Function formating ?
Formating for each row:
Example: =IF(B3>0;IF(B4<1490;TRUE;FALSE);FALSE)
ECT.
After some searching and testing, I came up with this:
=ArrayFormula(SUM(IFERROR(FIND(B2&B3;MID(CONCATENATE((TRANSPOSE($B$2:$I$33)));SEQUENCE(LEN(CONCATENATE((TRANSPOSE($B$2:$I$33))));1;1;1);len(B2&B3)))=1)*1))>1
Still need to make the functions more tidy (picture 2 and 3).
See if this is what you are looking for?
Conditional formatting with Custom formula in Range: A2:H:
=LAMBDA(NAME,OR(A1=NAME,A2=NAME,A3=NAME))("Gunslinger")
or do you means you want to highlight only duplicates?
If that is the case, you may try this formula:
=LAMBDA(DATARANGE,
LAMBDA(FLAT,
{{"Team","Duplicate"};{UNIQUE(FLAT),BYROW(UNIQUE(FLAT),LAMBDA(NAME,COUNTIF(FLAT,NAME)>1))}}
)(
QUERY(FLATTEN(
BYCOL(DATARANGE,LAMBDA(C,
BYROW(C,LAMBDA(R,
IF((ROW(R)+1)/4=INT((ROW(R)+1)/4),R,"")
))
))
),"SELECT Col1 WHERE Col1 IS NOT NULL",0)
)
)(A2:H)
This formula returns an array of unique Names with checking if there are Duplicates in the given datarange.
Combine this with the 1st formula should be able to highlight repeated data sets from your table.
Solution for 2 criteria matching:
The formula inside the image form the table of unique match results,
use that result with OR(), XLOOKUP(), OFFSET(), INDEX() as below for the final formula to put into the custom formula in conditional formatting.
=LAMBDA(RESULT,
LAMBDA(NAME,DUP,KEY,
LAMBDA(KEY_M2,KEY_M1,KEY_P1,
OR(
XLOOKUP(KEY_M2&"&&"&KEY_M1,NAME,DUP,FALSE),
XLOOKUP(KEY_M1&"&&"&KEY,NAME,DUP,FALSE),
XLOOKUP(KEY&"&&"&KEY_P1,NAME,DUP,FALSE)
)
)(IFERROR(OFFSET(KEY,-2,0),""),IFERROR(OFFSET(KEY,-1,0),""),IFERROR(OFFSET(KEY,1,0),""))
)(INDEX(RESULT,,1),INDEX(RESULT,,2),A2)
)(
LAMBDA(DATARANGE,
LAMBDA(FLATCLASS,
{{"Name","Duplicate"};{UNIQUE(FLATCLASS),BYROW(UNIQUE(FLATCLASS),LAMBDA(NAME,COUNTIF(FLATCLASS,NAME)>1))}}
)(
QUERY(FLATTEN(
BYCOL(DATARANGE,LAMBDA(C,
BYROW(C,LAMBDA(R,
IF((ROW(R)+1)/4=INT((ROW(R)+1)/4),IF(R="","",INDEX(C,ROW(R)-2)&"&&"&R),"")
))
))
),"SELECT Col1 WHERE Col1 IS NOT NULL",0)
)
)($A$2:$H)
)

How do I combine the output of multiple QUERY functions?

I have the following formula...
=ARRAYFORMULA( VLOOKUP( QUERY(results_sheet_1:range, query_string_1), lookups_sheet:range, 11, FALSE))
... which returns a single column of values.
I need to call this formula on multiple sheets (results_sheet_1, _2, _3 etc) and combine the output in a single column. The query string is different for each sheet, though in all cases only a single column is returned.
How can this be done?
Replace this:
...QUERY(results_sheet_1:range, query_string_1)...
with this:
{QUERY(results_sheet_1:range, query_string_1);QUERY(results_sheet_2:range, query_string_2);QUERY(results_sheet_3:range, query_string_3)}
Being sure to include the curly braces and semicolons between the ranges.

Find same word in 2 columns

I am trying to automate the analysis of a list by comparing 2 columns to see if they have the same word in them, for example:
I want to go through the words in Column B and check if they exist in Column C, then return a simple TRUE or FALSE.
I have tried everything I could, really appreciate the help!!
try:
=INDEX(IF(A1:A="",,MMULT(N(IFERROR(IF(SPLIT(A1:A, " ")="", 0,
REGEXMATCH(B1:B, "(?i)"&SPLIT(A1:A, " "))))),
SEQUENCE(COLUMNS(SPLIT(A1:A, " ")), 1, 1, 0))>0))
regexmatch is the function you want to look into. it only works on text, and is case sensitive. So you may need to convert the contents of the cells to all be uppercase.
Here is something you might want to look into
Is there a way to REGEXMATCH from a range of cells from A1:A1000 for example?

Can I exclude blanks / 0 from an ArrayFormula countif?

I have a simpe ArrayFormula:
=ArrayFormula(countif(I2:I,J2:J))
How do I filter out the null counts?
The results I expect are rows that actually have results. I don't want a sheet full of 0s.
try either this:
=ARRAYFORMULA(IF(LEN(I2:I), COUNTIF(I2:I, J2:J), ))
or this:
=ARRAYFORMULA(IF(LEN(J2:J), COUNTIF(I2:I, J2:J), ))
To avoid displaying all 0s in the relevant column (whether because 'I' or 'J' cell empty/blank) you might format it as:
#;

How to use ArrayFormula in Google Sheets, with multiple IF conditions?

So I just found out about ArrayFormula and am trying to convert my spreadsheet to utilize it, to be more efficient. Its worked wonderfully on all my columns except one, which is giving me trouble.
Currently, I have this formula in it (and copied to each cell):
=IF(C2="Immediate",
D2+1,
IF(C2="3 Day",
WORKDAY(D2,3,Holidays!$B$2:$B$11),
IF(C2="5 Day",
WORKDAY(D2,5,Holidays!$B$2:$B$11),
IF(ISBLANK(C2),
IFERROR(1/0)
)
)
)
)
It works wonderfully to calculate a date, based on a dropdown menu I have in another column. I cant figure out how to convert this to utilize ArrayFormula, as I get an error as soon as I add a second IF statement.
I can get the first statement to work with this formula:
=ARRAYFORMULA(IF(C2:C="Immediate",D2:D+1,))
But as soon as I try to add a second IF statement(such as with the formula below) I get an error.
How do I do this? I figure its probably simple but I cant figure it out!
Im trying to use a simpler formula to figure out where I am going wrong, and same thing will happen with the following formula so Im clearly doing something wrong!
=ARRAYFORMULA(IF(A1:A=1,"Hello",),IF(A1:A=2,"Goodbye",))
With only the first IF statement, it works. As soon as I add the second, I get #N/A
I know this is old but maybe try this formula:
={"Header_Cell_Name_Here";
ArrayFormula(
IFS(
$C$2:$C="","",
$C$2:$C="Immediate", $D$2:$D + 1,
$C$2:$C="3 Day", WORKDAY($D$2:$D,3,Holidays!$B$2:$B$11),
$C$2:$C="5 Day", WORKDAY($D$2:$D,5,Holidays!$B$2:$B$11)
)
)
}
IFS is a great alternative to IF. Rather than taking three arguments like you do with an IF statement:
IF(logical_expression, value_if_true, value_if_false)
an IFS statement can handle any number of conditions:
IFS(condition1, value1, [condition2, ...], [value2, ...])
Try this formula somewhere on row 1 of your sheet:
=ARRAYFORMULA(IF(A:A="",,IF(A:A=1,"Hello",IF(A:A=2,"Goodbye","Other Result"))))
you can use that formula
=ArrayFormula(IF(C2:C="",IFERROR(1/0),IF(C2:C="Immediate",D2:D+1,IF(C2:C="3 Day",WORKDAY(D2:D,3,Holidays!$B$2:$B$11),IF(C2:C="5 Day",WORKDAY(D2:D,5,Holidays!$B$2:$B$11),IF(ISBLANK(C2:C),IFERROR(1/0)))))))
here is an example
Your first formula, expanded to arrays, works perfectly well for me
=ARRAYFORMULA(IF(C2:C5="Immediate",
D2:D5+1,
IF(C2:C5="3 Day",
WORKDAY(D2:D5,3,Sheet2!$B$2:$B$11),
IF(C2:C5="5 Day",
WORKDAY(D2:D5,5,Sheet2!$B$2:$B$11),
IF(ISBLANK(C2:C5),
IFERROR(1/0)
)
)
)
)
)
This is the best arrayformula with multi if conditions I usually use
AND Operator
=Arrayformula(if(isblank(A2:A),,if((condition1) * (condition2) * (condition3),statement, if((condition1) * (condition2) * (condition3), statement, ))))
OR Operator
=Arrayformula(if(isblank(A2:A),,if((condition1) + (condition2) + (condition3),statement, if((condition1) + (condition2) + (condition3), statement, ))))
Example :
=Arrayformula(if(isblank(A2:A),,IF(((F2:F="Completed") * (J2:J <= 50)), $AT$3, IF(((F2:F="Completed") * (J2:J > 50) * (J2:J < 150)), $AT$4, IF(((F2:F="Completed") * (J2:J>150) * (J2:J < 250)), $AT$5, IF(((F2:F="Not_loaded") * (J2:J = 0)), $AT$6, 0))))))
Kindly note that braces are required to work correctly.

Resources