How to do an If Else in google sheets? - excel

Right now I'm trying to figure out whether a cell contains one of two values, it will then perform an operation which depends on whatever value is in said cell. This is the function I have so far:
=IF(ISNUMBER(SEARCH("btc", I2)), (E2*(1+10%)-D2),""), IF((ISNUMBER(SEARCH("pp",I2)),E2-D2,""))
However I found that you cannot do 2 if statements in the same cell.

Put your second in the false of the first instead of the "". It is called nesting:
=IF(ISNUMBER(SEARCH("btc", I2)), (E2*(1+10%)-D2),IF(ISNUMBER(SEARCH("pp",I2)),E2-D2,""))

Alternate with nested IFERROR functions.
=IFERROR(E2*IFERROR(SIGN(SEARCH("btc",I2))*110%,SIGN(SEARCH("pp",I2)))-D2,"")

Related

How to I remove duplicate words when using =TEXTJOIN() function in google sheets or excel

I am trying to find a function that I can use that will eliminate duplicate wording when i join two cells together. I will attach a picture to show you what my ideal return is.
Ideal Return
For the Row 1&2 column, this is the function I used (=textjoin(":",True,A2,B2)) , but i would like to find a function that will return me the Ideal Return instead. I am not looking to use the find and replace feature, as I would like to document each step I made, so a function would be best.
Use UNIQUE() function to remove duplicates. Try-
=TEXTJOIN(":",1,UNIQUE(FLATTEN(A2:B2)))
For dynamic spill results use BYROW() function. Try-
=BYROW(A2:B4,LAMBDA(x,TEXTJOIN(":",1,UNIQUE(FLATTEN(x)))))
To make input range dynamic (instead of fixed rows) can use-
=BYROW(A2:INDEX(B2:B,COUNTA(A2:A)),LAMBDA(x,TEXTJOIN(":",1,UNIQUE(FLATTEN(x)))))
What about this one?
=IF(EQ(A2;B2);A2;TEXTJOIN(":";true;A2;B2))
nothing fancy though, if you want the fancy one, the answer with flatten from Harun24hr is better.
But it is easy in what it does, if the cells are the same, then take the first cell, otherwise, concat the results.

Excel: missing something in writing an enumeration function

Up front let me say I can do this in VBA but I am trying to do it without using VBA with the assistance of the new LAMBA function.
I have a list, let us say A,B,C,D,C,E,B,B
what I am trying to write is an enumeration function which gives me the individual positions of set of identical items. So in the above example it would return a list 1,1,1,1,2,1,2,3 (the last item is a three because it is the 3rd "b" element etc). It is easy enough to do in cells with the answer in the next row:
a1:a8 contain A,B,C,D,C,E,B,B
b1 contains =COUNTIF(A1:$A$1,A1) and that gets dragged across all the columns
But I need the output in a dynamic array and something like b1
=COUNTIF(A1:$A$1,A1:H1) obviously won't work.
I've also tried writing a recursive LAMBDA statement which runs through a diminishing range but that gives me VALUE errors and is pretty complex in any case.
Any suggestions?
Use Offset inside the COuNTIFS:
=COUNTIF(OFFSET(A1,0,0,1,SEQUENCE(,COUNTA(1:1))),INDEX(1:1,,SEQUENCE(,COUNTA(1:1))))
For a non Volatile version use:
=MMULT(SEQUENCE(,COLUMNS(A1:H1),1,0),(A1:H1=TRANSPOSE(A1:H1))*(SEQUENCE(,COLUMNS(A1:H1))>=SEQUENCE(COLUMNS(A1:H1))))
With LET:
=LET(x,A1:H1,y,COLUMNS(x),MMULT(SEQUENCE(,y,1,0),(x=TRANSPOSE(x))*(SEQUENCE(,y)>=SEQUENCE(y))))

In Excel which formula can write that would easily identify if my output condition is true or false

I am trying to do an excel formula calculated response in regards to comparing the values of three cells.
I have three cells and if one or more cell is populated with a value of greater than "0" I want it to return mix and if false ignore
Yes, actually you're correct you'll need to use COUNTIF or IF. The function IF should be good enough depending on your formula.
Please try to use the formula how I had in illustrated in my image. =IF(D3>TODAY(),"YES","NO"), your formula would be different depending on your values or if you're using dates.
If you're not using dates you can still just use IF plus the AND functions like this "=IF(AND(B3,C3,D3)<="","TRUE","FALSE")", see my linked file to see how I did it. Good luck!
Tip, you can check for "0"(a number) or ""(which means blank).
Check Value in 3 Cells for TRUE-FALSE example in excel.
Screenshot that might help understand how I use '=IF(AND...' Functions to do just what you originally asked.
To answer the revision to your question I would recommend referencing Microsofts resource on CONCAT function Combine text and numbers
Conversely, I've worked out an example for you. =IF(E4>0,(CONCAT("YES: B4:D4 ="," ",(TEXT(C4,"MM/DD/YY"))," + ",(TEXT(D4,"MM/DD/YY"))," + ",D4," Total Days")),"NO") which references my example screen shot here:
The use of "IF" plus the "CONCAT" function to return the mix of three or more cell values.

Searching for multiple words and using IF/OR/Vlookup function

I'm trying to create a formula that will search a cell for the following words.. "Other" & "Repair" if either of these words are found I want it to be categorized as the word that is found. If none of these words are found I want the formula to Vlookup another column to then categorize it.
I got the formula to work for one search word, I cant figure out how to do it with two search words.
below is the formula I used for one word search criteria.
=IF(ISNUMBER(SEARCH("REPAIR",B9089)),"REPAIR",VLOOKUP(E9089,Key!$D:$E,2,0))
This is what I tried doing for the two search words but it breaks at the end for the true / flase statement
=IF(OR(ISNUMBER(SEARCH("REPAIR",B9090)),ISNUMBER(SEARCH("OTHER",B9090))),"REPAIR""OTHER",VLOOKUP(E9090,Key!$D:$E,2,0))
If you need to search for two values and the values returned, an OR statement will not work. Since it will only return true or false to an IF statement, and the IF will then return only one value. Instead, you can nest two IF statements inside each other for each of the values you need to find. Try the following formula:
=IF(ISNUMBER(SEARCH("Repair",B9089)),"Repair",IF(ISNUMBER(SEARCH("Other",B9089)),"Other",VLOOKUP(E9089,Key!$D:$E,2,0)))
(I am assuming your references and the Vlookup statement are correctly written by yourself)
I think you'll need nested IF statements, like this:
=IF(ISNUMBER(SEARCH("REPAIR",B9089)),"REPAIR", IF(ISNUMBER(SEARCH("OTHER",B9089)),"OTHER",VLOOKUP(E9089,Key!$D:$E,2,0))
What this does is first check if "REPAIR" is part of the speciified cell's value, if it isn't it checks if the cell value contains "OTHER", and if that is not the case it performs the desired VLOOKUP.
Please not that this is doable for two conditions, but if it starts getting to higher numbers you should consider writing a custom function in VBA.

Nested if/then statement syntax

I've been reading a bunch of answers around nesting if/then statements in Excel but I can't figure out how to fix a "formula parse error" in mine. From what I can tell and in my code editor the formula is correct. Any ideas what I'm missing here?
I have a row of cells that auto-generate a number 1-35 based on other values. I want the cell with the formula to pull data from another row based on what's the in row of numbers 1-35. It works when I test one at a time; it's the nesting that is causing the errors. Thanks!
=IF(E$167=1,C56,IF(E$167=2,D56,IF(E$167=3,E56,IF(E$167=4,F56,IF(E$167=5,G56,IF(E$167=6,H56,IF(E$167=7,I56,IF(E$167=8,J56,IF(E$167=9,K56,IF(E$167=10,L56,IF(E$167=11,M56,IF(E$167=12,N56,IF(E$167=13,O56,IF(E$167=14,P56,IF(E$167=15,Q56,IF(E$167=16,R56,IF(E$167=17,S56,IF(E$167=18,T56,IF(E$167=19,U56,IF(E$167=20,V56,IF(E$167=21,W56,IF(E$167=22,X56,IF(E$167=23,Y56,IF(E$167=24,Z56,IF(E$167=25,AA56,IF(E$167=26,AB56,IF(E$167=27,AC56,IF(E$167=28,AD56,IF(E$167=29,AE56,IF(E$167=30,AF56,IF(E$167=31,AG56,IF(E$167=32,AH56,IF(E$167=33,AI56,IF(E$167=34,AJ56,IF(E$167=35,AK56,””)))))))))))))))))))))))))))))))))))
You might have run into a function nesting limit. Try the choose function to work around it.
How about using
=IF(AND(E167>0,E167<36),OFFSET(B56,0,E167),"")
Note : OFFSET is a volatile function, see this for details.
A simple vlookup or hlookup function can do exactly what you need without righting long nested if statement.
for example you can use:
=vlookup(E$167,$A1:$B35,2,false) where $A1:$B35 is the table array containing column A (1-35) and column B its corresponding value.

Resources