I have successfully set up an 'IF' 'OR' formula that reviews the data of three cells and selects G unless one of the 3 cells contains an R in which case it displays R
=IF((OR('Jan 16'!B33="G",'Jan 16'!B34="G",'Jan 16'!B35="G")),"G","R")
The problem that I have is if there is no data populated into the logical test cells ('Jan 16'!B33, 'Jan 16'!B34 or 'Jan 16'!B35) the result is R. When the logical test cells contain no data I need the result to be blank.
Any help provided would be very much appreciated.
'IF' 'OR' formula that reviews the data of three cells and selects G
unless one of the 3 cells contains an R in which case it displays R
=IF((OR('Jan 16'!B33="G",'Jan 16'!B34="G",'Jan 16'!B35="G")),"G","R")
Alright, I'm not sure if that's what you meant to say or not, because right now, it is backwards. If any of the three cells contains a G, the formula will return G. All three cells would have to NOT contain G in order for it to return R. For example, even if you had data that was R|R|G, the formula would return a G (not R).
To get a formula as you've originally described, yet have it return blank if any of the three cells are blank, you could use this formula:
=IF(COUNTBLANK('Jan 16'!B33:B35)>0,"",IF(COUNTIF('Jan 16'!B33:B35,"R")>0,"R","G"))
To adjust your existing formula as you posted in your original question, you would use this:
=IF(COUNTBLANK('Jan 16'!B33:B35)>0,"",IF(COUNTIF('Jan 16'!B33:B35,"G")>0,"G","R"))
EDIT: Per additional requirement provided in comment:
Is there any way that I could add a third letter "Y"... so if in the
combination of three cells it is blank then return a blank, if in the
three cells there is an R return R, if in the three cells there is a Y
but no R then return Y and finally, if there are three G's return G
=IF(COUNTBLANK('Jan 16'!B33:B35)>0,"",IF(COUNTIF('Jan 16'!B33:B35,"R")>0,"R",IF(COUNTIF('Jan 16'!B33:B35,"Y")>0,"Y","G")))
Or if it specifically needs to look for 3x G:
=IF(COUNTBLANK('Jan 16'!B33:B35)>0,"",IF(COUNTIF('Jan 16'!B33:B35,"R")>0,"R",IF(COUNTIF('Jan 16'!B33:B35,"Y")>0,"Y",IF(COUNTIF('Jan 16'!B33:B35,"G")=3,"G","Invalid Data"))))
Related
Im trying to make sum.ifs formula to sum values in one row based on criteria.
In Criteria for Z I want to sum ALL Zs in table and same for D criteria.
Can I use sort of sum.ifs(A1:C1:E1;B1:D1:F1;G1) function? Unfortunately A1:C1:E1 trys to take range, not single cells and I get error...
What about this: (ugly but working)
=SUM(IF(A3:E3="Z",OFFSET(A3:E3,0,1),0))
It just goes over all cells (even the ones with the values are checked if they equal "Z", but as this is not the case (as they are values), they are skipped).
Edit (better formulated than the first one):
Next proposal:
=SUM(IF($A3:$E3=F$2,OFFSET($A3:$E3,0,1),0))
The dollarsigns are meant for fixing rows and/or columns:
$A3:$E3 : we will always be working with columns A to E, but the rows may change.
F$2 : the criteria are always on row 2, but some are in column F ("Z")
and some in column G ("D").
Place this in G3
=SUMIF(A3:E3,{"=Z","=D"},B3:F3)
The range A3:E3 is checked for the criteria of "=Z" and "=D" in turn, and the range over B3:F3 is then summed.
If you have Office 365 you could use: =SUM(FILTER(B3:F3,COUNTIF(G2:H2,A3:E3)>0))
Not sure if you wanted all summed at once or per letter. To have sum per letter use:
=SUM(FILTER(B3:F3,COUNTIF(G2:H2,A3:E3)>0)) and drag to the right
I am trying to do a summation of rows with certain dynamic conditions. I have rows like:
A can be only one value, K can have multiple OR-values. In the end M is to be summed.
I have tried to use SUMPRODUCT() which works for column A but not for K. What I am looking for is something like:
=SUMPRODUCT(--(!$A$2:$A$20000="AA")*--(!$K$2:$K$20000="AA" OR "BB")*$M$2:$M$20000)
I know I can do ="AA" and then ="BB" but I need "AA" and "BB" to be dynamic based on other cells. And the number of arguments is different. I tried {"AA";"BB"} but I know this will not work as the match then needs to be in the same row.
Can it at all be achieved?
Thanks a lot!
=SUMPRODUCT(($A$2:$A$20000="AA")*(($K$2:$K$20000="AA")+($K$2:$K$20000="BB"))*$M$2:$M$20000)
Note that:
Since you are multiplying/adding arrays, there's no need to include the double unary's
I don't know why you have a ! in your example formula.
To return an OR array of TRUE;FALSE, we add.
Your comments still do not provide a clear explanation of what you are making dynamic.
But to create a dynamic OR for column K, including testing for column A and summing column M, you can do the following:
For column K, let us assume that your possible OR's are entered separately in the range F2:F10
=SUMPRODUCT(MMULT(--($K$2:$K$20000=TRANSPOSE($F$2:$F$10)),--(ROW($F$2:$F$10)>0))*($A$2:$A$20000="AAA")*$M$2:$M$20000)
The matrix multiplication will produce a single column of 19,999 entries which will be a 1 for matches of any of the OR's and 0 if it does not match.
See How to do a row-wise sum in an array formula in Excel?
for information about the MMULT function in this application.
In the above formula, "blanks" in the OR range (F2:F10) will also match blank entries in column K. So it is conceivable that if there is a blank in K and F and a AAA in col A and a value in column M that a wrong result might be returned.
To avoid that possibility, we can use a dynamic formula to size column F where we are entering our OR values:
=INDEX($F$2:$F$10,1):INDEX($F$2:$F$10,COUNTA($F$2:$F$10))
will return only the values in col F that are not blank (assuming no blanks within the column)
So:
=SUMPRODUCT(MMULT(--($K$2:$K$20000=TRANSPOSE(INDEX($F$2:$F$10,1):INDEX($F$2:$F$10,COUNTA($F$2:$F$10)))),--(ROW(INDEX($F$2:$F$10,1):INDEX($F$2:$F$10,COUNTA($F$2:$F$10)))>0))*($A$2:$A$20000="AAA")*$M$2:$M$20000)
Given this data:
the last formula will return a value of 5 (sum of M2,M3,M7)
Use SUMIFS with SUMPRODUCT wrapper:
=SUMPRODUCT(SUMIFS($M$2:$M$20000,$A$2:$A$20000,"AA",$K$2:$K$20000,{"AA","BB"}))
The blue columns is the data given and the red columns is what is being calculated. Then the table to the right is what I am referencing. So, F2 will be calculated by the following steps:
Look at the Machinery column (D), if the cell contains LF, select column K, otherwise select column L
Look at the Grade column (E), if the cell contains RG, select rows 4:8, otherwise select rows 9:12.
Look at the Species column (A), if the cell contains MS, select rows 5 and 10, otherwise.......
Where every the most selected cell is in columns K and L, copy into column F.
Multiply column F by column C.
I don't want to make another column for my final result. I did in the picture to show the two steps separately. So column F should be the final answer (F2 = 107.33). The reference table can be formatted differently as well.
At first, I tried using nested-if statements, but realized that I would have like 20+ if statements for all the different outcomes. I think I would want to use the SEARCH function to find weather of not the cell contains a specific piece of information. Then I would probably use some sort of combination of match, if, v-lookup, index, search, but I am not sure how to condense these.
Any suggestion?
SUMPRODUCT is the function you need. I quickly created some test data on the lines of what you shared like this:
Then I entered the below formula in cell F2
=SUMPRODUCT(($I$4:$I$9=E2)*($J$4:$J$9=LEFT(A2,FIND(" ",A2)-1))*IF(ISERROR(FIND("LF",D2,1)),$L$4:$L$9,$K$4:$K$9))
The formula may look a little scary but is indeed very simple as each sub formula checks for a condition that you would want to evaluate. So, for example,
($I$4:$I$9=E2)
is looking for rows that match GRADE of the current row in range $I$4:$I$9 and so on. The * ensures that the arrays thus returned are multiplied and only the value where all conditions are true remains.
Since some of your conditions require looking for partial content like in Species and Machine, I have used Left and Find functions within Sumproduct
This formula simply returns the value from either column K or L based on the matching conditions and you may easily extend it or add more conditions.
I have a sheet that in Column M it has Date Visited and then I have put in a formula that then adds 6 months to the date which is displayed in Column N.
Then I have a hidden two columns that works out the date and and from that date it has been RAG assessed, Red Amber Green.
Column M is Date Visited
Column N is Next Visited
Column Q is the formula that tells you how many days over or under
Column R is where based on Column Q if it is G, A , R (Green, Amber or Red)
I have this formula which list all the dates and removes any blank cells in column N
=IFERROR(INDEX(Sheet2!$N$3:$N$78, SMALL(IF(LEN(Sheet2!$N$3:$N$78)=0,"", ROW(Sheet2!$N$3:$N$78)-MIN(ROW(Sheet2!$N$3:$N$78))+1), ROW(Sheet2!N2))),"")
What I want is when the below formula is true then the above to be triggered but only for cells that have R in Column R
=IF (CNI!R3="R",SHEET2!N3,"")
Hope this makes sense.
I don't mind using VBA if it is easier to achieve
Sorry, I'm a couple days behind on responding to you for this.
=IFERROR(INDEX(Sheet2!$N$3:$N$78, SMALL(_
IF(LEN(Sheet2!$N$3:$N$78)=0,"", ROW(Sheet2!$N$3:$N$78)-MIN(ROW(Sheet2!$N$3:$N$78)_
)+1), ROW(Sheet2!N2))),"")
But you want the this to happen if you have an additional criteria, this:
=IF (CNI!R3="R",SHEET2!N3,"")
You can have multiple criteria in your if statement using AND(). I am thinking that you could use the following, presuming you only want that specific If statement to apply (taken from the above, broken out If statement in the first coding section of my post):
IF(AND(CNI!R3="R",LEN(Sheet2!N$3:$N$78)=0),"", ROW(Sheet2!$N$3:$N$78)-MIN(ROW(Sheet2!$N$3:$N$78)
If your goal is to replace (from your second bit of code) the Sheet2!N3 (your true condition), then you would look at the following line, which includes both lines of your code:
=IF (CNI!R3="R",IFERROR(INDEX(Sheet2!$N$3:$N$78, SMALL(IF(LEN(Sheet2!$N$3:$N$78)=0,"", ROW(Sheet2!$N$3:$N$78)-MIN(ROW(Sheet2!$N$3:$N$78))+1), ROW(Sheet2!N2))),""),"")
Let me know if that helps clear up the issue!
I have a sheet with the following demo data (yeah the content is german don't mind that)
And I need a formula which will search for the criteria in A1 and B1 and returns the respective value out of the matrix E3:M8
For example
Search criteria is: X and 2 - Return value should be wert2
or
Search criteria is: Z and 1 - Return value should be wert7
I think I can somehow use an INDEX formula but not quite sure how to do so..
Hope you can help
It looks as if your data has merged cells. If you want to keep life simple, avoid merged cells.
Your data has the same 1,2,3 sequence in each section x, y and z. I assume that these values will always be the same. With the data laid out like in your screenshot, the formula you need is
=INDEX($E$3:$M$7,MATCH(B1,$E$3:$E$7,0),MATCH(A1,$E$3:$M$3,0)+2)
Because of the merged cells it is impossible to select the range in column E for the first Match function. It needs to by typed instead. You also need to adjust the second Match result for the column, since the x, y, and z are stored in the first of the merged three cells, but you want the value underneath the third of the merged cells. Avoid merged cells.
A better data layout would be this:
The Index/Match could be simplified to
=INDEX($E$3:$H$7,MATCH(B1,$E$3:$E$7,0),MATCH(A1,$E$3:$H$3,0))
Or you could use Vlookup
=VLOOKUP(B1,$E$3:$H$7,MATCH(A1,$E$3:$H$3,0),FALSE)