I currently have a large nested IF statement that uses a helper cell (C1) to dictate which formula to utilize based on numbers 1,2,3,5 & 6. Specifically, one IF statement within the larger nested IF statement needs to be updated for instances when there is a blank cell in column A. Here is how my workbook is setup:
Data Tab
Bonus Tab
Summary Tab
This is my current formula in Column B:
=IF(Data!$C$1=2,IF(SUM(Bonus!B2:C2)<1,0,1)*Data!$B$3+Data!$B$2)
What I am looking for is when cells in column A are blank, than the corresponding cell in Column B would be 0. Again, the formula above has to remain in the =IF(Data!$C$1=2, format since it is part of a larger nested IF statement.
Answer I am seeking:
Thank you for looking!
Try this:
=IF(Summary!A2="",0,IF(Data!$C$1=2,IF(SUM(Bonus!B2:C2)<1,0,1)*Data!$B$3+Data!$B$2))
How about adding an IF in there like this?
=IF(Data!$C$1=2,
IF(LEN(Summary!A2)>0,1,0)*
(IF(SUM(Bonus!B2:C2)<1,0,1)*Data!$B$3 + Data!$B$2))
or like this
=IF(Data!$C$1=2,
IF(LEN(Summary!A2)>0,
IF(SUM(Bonus!B2:C2)<1,0,1)*Data!$B$3 + Data!$B$,
0))
What about:
=IF(AND($C$1=2,LEN(A2)>0),IF(SUM(Bonus!B2:C2)<1,0,1)*Data!$B$3+Data!$B$2)
I realise this gives you FALSE rather than 0 at the end, but I don't know what the rest of your 7 IF statements look like.
EDIT
Based on #AlexisOlson 's comment:
=1*IF(AND($C$1=2,LEN(A2)>0),IF(SUM(Bonus!B2:C2)<1,0,1)*Data!$B$3+Data!$B$2)
This now returns 0 when Column A is blank, as required.
Related
How do I find either the cell address or preferably the row and column of the value 119, or any other number in the table below?
The table does not contain row or column titles, only the numbers as shown.
I am looking for a worksheet solution (formula) and not a VBA solution.
An Array Formula
This is an array formula and it has to be entered with control shift enter i.e. hold control shift and then press enter.
=MAX(IF(A1:J34=119,ROW(A1:J34)-ROW(A1)+1))
Remarks:
The value is searched by column i.e. A1, A2, ... B1, B2 ... i.e. if you had another 119 in cell D1 the result would still be 2, and if you had a 119 in cell c1 then the result would be
1.
For a column version just replace ROW with COLUMN:
=MAX(IF(A1:J34=119,COLUMN(A1:J34)-COLUMN(A1)+1))
Well, clunky and you can expand it, but it does work:
Row is separate to column but you could put them together in one cell, does depend on how you want to use the results, but you did not specify that so I have done this...
You could use a choose() function or a lookup table with vlookup() to change the column result to a letter...
Please try:
=MOD((K1-50),34)+1&" | "&1+(INT((K1-50)/34))
where K1 is your selected value.
Returns R | C. (Data in A1:J34 is not required.)
Below is a general purpose answer based on VBasic2008's answer.
I modified the formulas to utilize defined names so that the cell references do not have to be hard coded in the formulas. This way both the data table and row / column formulas can be relocated to anywhere on the spreadsheet. It works for both numerical AND text based data.
I also included the =ADDRESS() function to return the absolute reference of the look up value.
For illustration purposes, a step by step example for Data Set 1 is shown replacing the hard coded cell references with defined names.
The Data Set 2 section is the simplified version just using one defined for each the row and column look up value.
You can download an example spreadsheet here: Look_Up_a_Value_in_a_Table.xls
Thanks to all of you: Solar Mike, VBasic2008, and pnuts
Click on the image to enlarge.
This is probably a simple fix (although me thinking this, means it probably isn't), so I apologize in advance if this is mere child's play.
In an excel sheet I am working on, I have a range (for the sake of this example is B1:B10) which can contain one of 5 variables (not including blanks) - OG, D, L, PP or C.
I require a formula in another cell to review the range in question and output a value based on the following rules in this priority:
If OG appears anywhere in the column, regardless of other inputs, display OG;
If D and L and/or PP and/or C appear in the column, display OG;
If only D appears in the column, display D;
If only PP appears in the column, display PP;
If only L appears in the column, display L;
If only C appears in the column, display C; and
If all cells within the column are blank, display blank
For rules 1-6, any blank cells within the column should not be considered. It is only where all cells are blank, i.e. rule 7, that this should be considered.
I have tried IF formulas but have found these only consider a single cell.
I've tried searching everywhere and can't find anything on this (although this is probably down to me not phrasing my question/searches correctly).
Any help would be much appreciated. Thanks in advance!
Use an 'if' formula, but for your condition, Use 'MATCH': for eg, for checking the first case:
=IF(MATCH("OG",$B$1:$B$10,0), "OG", "FALSE")
The above formula will put "OG" if it's in any of the cells, else "FALSE".
In a similar way, change all your logic, but set the conditions to use match to see if they exist somewhere in the column
Here is a possible solution. For your 6 first tests, you type each of these formulas in a cell (I did it from D1 to D6) :
Test 1 (D1)
=IF(COUNTIF(B1:B10;"OG");"OG";"")
Test 2 (D2)
=IF(AND(COUNTIF(B1:B10;"D");OR(COUNTIF(B1:B10;"L");COUNTIF(B1:B10;"C");COUNTIF(B1:B10;"C";"")));"OG";"")
Test 3 (D3)
=IF(COUNTIF(B1:B10;"D")=DCOUNTA(B1:B10);"D";"")
Do the same for test 4 to 6 by replacing "D" by "P","L","C".
Now your target cell :
=IF(D7="empty";"";INDEX(D1:D7;MATCH(TRUE;INDEX((D1:D7<>"");0);0)))
This last cell will simply show the first non empty value of your test cells.
The last test is kind of implicit.
I hope I got your tests right, let me know if not.
EDIT : Sorry for the numerous editings, my Office isn't in English, that's a pain to translate the formulas. They should be working now.
EDIT 2 : Your last test is not implicit and there is a possibility that last cell show "NA". So you should add this to D7 :
=IF(COUNT(B1:B10)=0;"empty";"*A value to show if all tests didn't pass*")
Also now your target cell has D7 in its formula's range.
I feel condition 2 little confusing, Do you mean D is mandatory and other (L,PP,C) are option to result "OG" ?
What should be the result if we have multiple input of (L,PP,C) in the range ? Should it be BLANK?
I came up with this formula if D is mandatory in condition 2 and formula will return Blank if only other 3 inputs are there except "OG" and "D"
Formula: =IF(COUNTIF(B1:B10,"OG")>0,"OG",IF(AND(COUNTIF(B1:B10,"D")>0,SUM(COUNTIF(B1:B10,"D"),COUNTIF(B1:B10,"L"),COUNTIF(B1:B10,"PP"),COUNTIF(B1:B10,"C"))>1),"OG",IF(COUNTIF(B1:B10,"D")=COUNTA(B1:B10),"D",IF(COUNTIF(B1:B10,"L")=COUNTA(B1:B10),"L",IF(COUNTIF(B1:B10,"PP")=COUNTA(B1:B10),"PP",IF(COUNTIF(B1:B10,"C")=COUNTA(B1:B10),"C",""))))))
First Condition:
Condition 2:
Condition 3:
Condition 4:
Condition 5:If there is no "OG" or "D" in the array formula returns Blank.
I'm working on a budget for a project with multiple phases. There is a possibility that not all phases will be worked on so I've added some lookups and SUMIF formulas so that I can get a summary of my included and excluded effort and dollar amounts. That all works fine. Now I'd like to hide my row of lookups (row 1), but still have a way of identifying which phases of the project are included and which are excluded. Obviously I could manually concatenate them together, but if the phases being included/excluded change then I need to remember to update those formulas (and it's not nearly as fun as doing all in a formula). Here's how my sheet looks:
The TEXTJOIN function seems like it should work (i.e. =TEXTJOIN(CHAR(10), TRUE, C2:N2)), but I can't wrap my head around how to make the range parameter dependent on my lookup row. I played around with INDEX using something like =TEXTJOIN(CHAR(10), TRUE, INDEX(A2:M2,,(A1:M1="Yes")*COLUMN(A1:M1))), but didn't have any luck. At the end of the day I want to have something like:
Phase 1 Phase 2 Phase 5
Please note that the above data should all appear in the same cell - using the line feed character, CHAR(10), as the delimiter in the TEXTJOIN function will make all of the phases appear on a new line within a single cell. I do not want to fill formulas through multiple cells. Thanks in advance for any help.
Please take a look at the picture. I had a similar issue in the past (and brought it to StackOverflow, at which point I was helped by #ScottCraner, original post here:
Doing an array formula lookup
Basically,
1) You set up the array you are looking through - in my case, its $A$2:$A$6, in your case it will be $B$2:$M$2.
2) You then nest the COUNTIFS function inside of a match function. The function does the following:
A) It checks whether the name of phase X has already shown up in column E when you are copy/pasting down
B) If it has, move on to the next one
C) If it hasn't, output
3) Of note: this is an array formula, so the formula itself is checking through every cell. So it looks at cell A2; if the cell in B2 is "Yes", and "Phase 1" isn't in range in column E, then put in phase 1. Because it is, its there. Then it looks at cell A3; if the cell in B3 is "Yes", the same thing for phase 2. Then it looks at cell A4; because B4 is "No", the *(B2:B6="Yes") will throw an error. and so on
4) Place error catching brackets around the function.
A less elegant way to go about this, which doesn't require array formulas would be to use the secondary column's "Yes/No" as an index. This assumes the value in the secondary column is redundant- and repeating the primary column's "Yes" or "No."
In C1: =CONCATENATE(B1,COUNTIFS($A$1:B1,B1)) -
Repeat relatively for E1, G1, etc.
Somewhere separate (the below formula assumes Row 1 of the same worksheet), you could then use: =IFERROR(INDEX($2:$2,MATCH(CONCATENATE("Yes",ROW()),$1:$1,0)-1),"")
To look up "Yes1", returning "Phase 1" and autofill downward. IFERROR is used here to return blank when you run out of "Yes" results.
I am new to using nested if functions in excel. I would like to find out what the correct functions for my excel spreadsheet.
if the pH is <7.35 and the PaCO2 is >6.00, or if the WOB is documented as a yes. I would like to the cell to return a yes response and if not the cell should return a no response.
if 6 columns in my spreadsheet all have yes responses eg a1,b1,c1,d1,e1,f1, i would like the cell in the 7th column i.e. g1 to return a yes response. however if any cell in a1,b1,c1,d1,e1,f1 has either a no , unknown or blank response , g1 should return a no response.
I would be grateful if someone could help me with this by tomorrow - as it is for a work project. Thank you
Lets assume question 1 in on one sheet and question 2 is on another for sake of example. Simply transpose to your case:
If pH is in column A, PaCO2 is in column B, and WOB is in column C, your formula would look like this =IF(OR(AND(A1<7.35,B1>6),C1="YES"),"YES","NO") and paste this in the desired column on row 1. You can copy this down for all applicable rows.
For your second enquiry, I wouldn't use a nested if statement as it restricts you to only the 6 cells you have listed. The following formula will work for as many cells as you like =IFERROR(INDEX(A1:F1,MATCH("NO",A1:F1,0)),"YES"). In this case, you would simply expand your column set for both instances of A1:F1
The nested If statements would look like this (if you choose to go that direction): =IF(A1="NO","NO",IF(B1="NO","NO",IF(C1="NO","NO",IF(D1="NO","NO",IF(E1="NO","NO",IF(F1="NO","NO","YES"))))))
How can I simplify this with VLOOKUP or LOOKUP?
IF(OR(A1=1,A1=2,A1=3,A1=4,A1=5,A1=6,A1=7),"Yes","No")
is there any way to make it more robust using VLOOKUP or any other Excel function to avoid this many or conditions?
Basically that OR condition is the same as A1<8 so just do that and get rid of the OR.
=IF(A1<8,"Yes","No")
in this example i have a list in Sheet 2 in the A column that contains all the values. In sheet 1 in cell A1 I enter the test number and you can put this formula in any cell you want
=IF(LOOKUP(A1,Sheet2!A:A,Sheet2!A:A)=A1,"Yes","No")
A bit better:
=IF(ISERROR(FIND("|"&A1&"|", "|1|2|3|4|5|6|7|")), "No", "Yes")
Assumes no one ever puts "|" into A1
This is the same:
=IF(AND(A1>0,A1<8,INT(A1)=A1),"Yes","No")
If I'm understanding correctly, you have a value in cell, say A1, and a variety of other values in cells B1:B8 and you'd like to know whether A1 matches any value present in B1:B8.
You could set up a flag variable taking value 1 if a match is found and 0 if not as follows:
=1-ISNA(MATCH(A1,B1:B8,0))
Alternatively, you could do something like:
=IF(ISNA(MATCH(A1,B1:B8,0)),"No","Yes") to output something more similar to the above.