How to give a value to a column based on other columns - excel

I have a excel sheet.
I have many values going down columns 1,2,3 (1000) and I want to have a new column, 5, which returns the following value depending on what is in the other cells:
if column 4 is Y, return N

Just some straightfoward logic with IF, AND, and NOT:
=IF(D2,"Going",IF(AND(A2,B2,NOT(C2)),"Away",IF(AND(NOT(A4),NOT(B4),C4),"Soon")))
Note that this formula will return FALSE for any possibilities besides the three you outlined. If that's not desired, you can add "" for example as the last option: ...,"Soon","".

This is you can achieve with simple if formula -
IF(D2=TRUE, "GOING", IF(AND(A2=TRUE,B2=TRUE,C3=FALSE),"AWAY",IF(AND(A2=FALSE,B2=FALSE,C2=TRUE),"SOON")))
Note - if cells has value as TRUE FALSE only then use it in formula without "" else you should use "" for other text.

Try this formula #D2
IF(D2=TRUE,"GOING",IF(AND(A2=TRUE,B2=TRUE,C2=FALSE),"AWAY",IF(AND(A2=FALSE,B2=FALSE,C2=TRUE),"SOON","NA")))

Related

Does anyone know how to perform a horizontal xlookup

Does anyone know there is a cleaner way to write XLOOKUP formula to perform this lookup function.
The current formula looks like this, it becomes very long if there are many columns to lookup.
=xlookup(H2,$A$1:$A$9,$F$1:$F$9,xlookup(H2,$B$1:$B$9,$F$1:$F$9,xlookup(H2,$C$1:$C$9,$F$1:$F$9,xlookup(H2,$D$1:$D$9,$F$1:$F$9,"",0))))
A horizontal lookup is not the issue here as the function can both lookup a value in a 1D horizontal or vertical range of cells. But you can't use XLOOKUP() to find a value in a 2D-array like that, however; with those numeric case ID's and the use of Microsoft365, you could try:
=MAX(IF(A2:D6=H2,F2:F6))
You may also try-
=INDEX(F1:F9,MAX((A1:D9=H2)*(ROW(A1:D9))))
You could use: =INDEX($F$2:$F$9,SUMPRODUCT(($A$2:$D$9=H2)*ROW($A$2:$D$9)))
Note: This only works if there's only one match.
It checks if $A$2:$D$9=H2 where TRUE = 1 and FALSE = 0. Than multiplies that with the row number of the cell in that range. All FALSE result in 0*row number = 0 where TRUE results in 1*row number = row number.

Return a value in a column base on condition Use Ifs or Hlookup, Vlookup

I Try to return data in column J to the table, If "Number of lesson" are equal and the column name "F1,F2,F3" are equal to data in "Flow" column, and I use IF but it just apply for 1 cell, How to use IFs or other methods?
What i try:
=IF(and($C3=H4, D$2= I4),$J4,false)
there are a couple of versions of how this can be done with one formula
сase 1: copy this formula into cell D3
=ArrayFormula(sumif(H4:H15&I4:I15,C3:C11&D2:F2,J4:J15))
case 2: if you really need to specify False instead of zero values, then write this formula in cell D3
=ArrayFormula(REGEXREPLACE(TO_TEXT(sumif(H4:H15&I4:I15,C3:C11&D2:F2,J4:J15)),"^0$","False"))

How to create an excel formula with IF along with AND and multiple OR conditions

I'm looking to create an IF statement with AND and multiple OR conditions from two sheets. Basically, first thing that Excel should do is check Column A if the cell value is blank or not. Then once it has this determined, it should check Columns B, C, D if any of them has values or not. If any one of these 3 columns has value, set to True. And if all 3 columns is blank, set to False.
I have tried these formulas;
=IF(AND(Raw!AK6<>"",OR(Raw!AM6<>"",Raw!AN6<>"",Raw!AO6<>"")),"",Raw!D6)
and also;
=IF(AND(Raw!AK3<>"",OR(Raw!AM3<>"",OR(Raw!AN3<>"",OR(Raw!AO3<>"")))),"",Raw!D3)
Thanks in advance!
You can use the formula ISBLANK() and invert the concepts:
=IF(OR(ISBLANK(Raw!AK6),AND(ISBLANK(Raw!AM6),ISBLANK(Raw!AN6),ISBLANK(Raw!AO6))),Raw!D6,"")
See results (Column D = "Yes"):
Use COUNTIFS:
=IF(AND(Raw!AK3<>"",COUNTIFS(AM3:AO3,"<>")>0),Raw!D3,"")
But basically your first formula would work, you just have the TRUE/FALSE reversed:
=IF(AND(Raw!AK6<>"",OR(Raw!AM6<>"",Raw!AN6<>"",Raw!AO6<>"")),Raw!D6,"")

Finding value that does not match while using SumProduct formula

In the following formula I sum up values in a column, I like to expand this so that it discounts values, if a value in another column ends with a "*D".
So far I have got it so that it sum only those that end in a "*D".
=SUMPRODUCT(SUBTOTAL(9,OFFSET($DY$16,ROW($DY$16:$DY$273)-ROW($DY$16),,1)),--ISNUMBER(SEARCH("*D",$EB$16:$EB$273)))
Question 1: How to reverse the formula to exclude value "*D"?
The --ISNUMBER part of your formula evaluates TRUE whenever the "D" is located
Changing this part to -ISERROR will evaluate TRUE whenever the "D" is not located
=SUMPRODUCT((IFERROR(SEARCH("D",CategoryRange),"-")<>LEN(CategoryRange))*SumRange)
should work if there is only on D.
CategoryRange is the range of cells in Category code column and SumRange is the range of cells in column to be summed over
It works for me. IFERROR(SEARCH("D",CategoryRange),"-") finds the position of 'D' in the Categore Code column, if it is not equal to LEN(CategoryRange) then the 'D' is not at the end, which creates a boolean array that you want. Please check it stepwise with "Evaluate Formula" in excel.

IF statement: how to leave cell blank if condition is false ("" does not work)

I would like to write an IF statement, where the cell is left blank if the condition is FALSE.
Note that, if the following formula is entered in C1 (for which the condition is false) for example:
=IF(A1=1,B1,"")
and if C1 is tested for being blank or not using =ISBLANK(C1), this would return FALSE, even if C1 seems to be blank. This means that the =IF(A1=1,B1,"") formula does not technically leave the cells blank if the condition is not met.
Any thoughts as to a way of achieving that? Thanks,
Unfortunately, there is no formula way to result in a truly blank cell, "" is the best formulas can offer.
I dislike ISBLANK because it will not see cells that only have "" as blanks. Instead I prefer COUNTBLANK, which will count "" as blank, so basically =COUNTBLANK(C1)>0 means that C1 is blank or has "".
If you need to remove blank cells in a column, I would recommend filtering on the column for blanks, then selecting the resulting cells and pressing Del. After which you can remove the filter.
Try this instead
=IF(ISBLANK(C1),TRUE,(TRIM(C1)=""))
This will return true for cells that are either truly blank, or contain nothing but white space.
See this post for a few other options.
edit
To reflect the comments and what you ended up doing: Instead of evaluating to "" enter another value such as 'deleteme' and then search for 'deleteme' instead of blanks.
=IF(ISBLANK(C1),TRUE,(TRIM(C1)="deleteme"))
I wanted to add that there is another possibility - to use the function na().
e.g. =if(a2 = 5,"good",na());
This will fill the cell with #N/A and if you chart the column, the data won't be graphed. I know it isn't "blank" as such, but it's another possibility if you have blank strings in your data and "" is a valid option.
Also, count(a:a) will not count cells which have been set to n/a by doing this.
If you want to use a phenomenical (with a formula in it) blank cell to make an arithmetic/mathematical operation, all you have to do is use this formula:
=N(C1)
assuming C1 is a "blank" cell
You could try this.
=IF(A1=1,B1,TRIM(" "))
If you put this formula in cell C1, then you could test if this cell is blank in another cells
=ISBLANK(C1)
You should see TRUE. I've tried on Microsoft Excel 2013.
Hope this helps.
I've found this workaround seems to do the trick:
Modify your original formula:
=IF(A1=1,B1,"filler")
Then select the column, search and replace "filler" with nothing. The cells you want to be blank/empty are actually empty and if you test with "ISBLANK" it will return TRUE. Not the most elegant, but it's quick and it works.
The easiest solution is to use conditional formatting if the IF Statement comes back false to change the font of the results cell to whatever color background is. Yes, technically the cell isn't blank, but you won't be able to see it's contents.
This shall work (modification on above, workaround, not formula)
Modify your original formula:
=IF(A1=1,B1,"filler")
Put filter on spreadsheet, choose only "filler" in column B, highlight all the cells with "filler" in them, hit delete, remove filter
You can do something like this to show blank space:
=IF(AND((E2-D2)>0)=TRUE,E2-D2," ")
Inside if before first comma is condition then result and return value if true and last in value as blank if condition is false
The formula in C1
=IF(A1=1,B1,"")
is either giving an answer of "" (which isn't treated as blank) or the contents of B1.
If you want the formula in D1 to show TRUE if C1 is "" and FALSE if C1 has something else in then use the formula
=IF(C2="",TRUE,FALSE)
instead of ISBLANK
Here is what I do
=IF(OR(ISBLANK(AH38),AH38=""),"",IF(AI38=0,0,AH38/AI38))
Use the OR condition OR(ISBLANK(cell), cell="")
I think all you need to do is to set the value of NOT TRUE condition to make it show any error then you filter the errors with IFNA().
Here is what your formula should look like =ifna(IF(A1=1,B1,NA()))
Here is a sheet that returns blanks from if condition :
https://docs.google.com/spreadsheets/d/15kWd7oPWQmGgYD_PLz9YpIldwnKWoXPHtHQAT3ulqVc/edit?usp=sharing
Nope ... that only works for Googlesheets ... not Excel.
To Validate data in column A for Blanks
Step 1: Step 1: B1=isblank(A1)
Step 2: Drag the formula for the entire column say B1:B100; This returns Ture or False from B1 to B100 depending on the data in column A
Step 3: CTRL+A (Selct all), CTRL+C (Copy All) , CRTL+V (Paste all as values)
Step4: Ctrl+F ; Find and replace function Find "False", Replace "leave this blank field" ; Find and Replace ALL
There you go Dude!
Instead of using "", use 0. Then use conditional formating to color 0 to the backgrounds color, so that it appears blank.
Since blank cells and 0 will have the same behavior in most situations, this may solve the issue.
This should should work: =IF(A1=1, B1)
The 3rd argument stating the value of the cell if the condition is not met is optional.

Resources