I'm creating a report where I need to count all entries where (column a = x or column b = x or column c = x) and (column d <> x or y or z)
I'm open to any solutions scripted or expression.
Thank you.
_t
=sumproduct(NOT(NOT(((A:A="X")+(B:B="X")+(C:C="X"))))*((D:D<>"X")*(D:D<>"Y")*(D:D<>"Z)))
This is with the assumption that an entire row is considered the entry not each individual cell.
This can be computationally intensive with full column reference. Better if used over a defined range.
You can use the following array formula, just adjust the variables "X, Y, Z" to whatever you criteria you need it to be and change the range to fit your range of data.
=COUNTIF(A1:A10,"X")+COUNTIF(B1:B10,"X")+COUNTIF(C1:C10,"x")+SUM((D1:D10<>"X")*(D1:D10<>"Y")*(D1:D10<>"Z"))
You have to press CTRL + SHIFT + Enter to calculate this array formula, will not work with a standard enter.
Related
Is there any formula that can count in two columns and only return the unique count.
I have a table where two columns could have an "X", I want to count the "or" of this "X".
Meaning if it's in one or the other or both column(s) then count that, else don't.
Example:
A B C
foo X
bar X
Doo X X
Boo
The expected result is 3 (foo, bar, Doo).
I can't do a =COUNTIF(B:B, "X") + COUNTIF(C:C, "X") since that will give me 4.
=COUNTIF(B:C , "X") returns 4.
SUMPRODUCT((B:B="X")*(C:C="X")*1) = 1, SUMPRODUCT((B:C="X")*1) = 4
Is there any formula that could count this case?
Sadly I don't have Office 365 at work
If one has Excel O365, you could try:
=COUNTA(UNIQUE(FILTER(A:A,(B:B="X")+(C:C="X"))))
If you have an older version of Excel, maybe try:
=SUM(--(FREQUENCY(IF((B1:B4="X")+(C1:C4="X")>0,MATCH(A1:A4,A1:A4,0)),ROW(A1:A4))>0))
Not, this last formula is an CSE-entered formula in Excel prior to O365. Also, if your data starts at a different row you'd need to adjust the formula accordingly. See this link that will explain how.
If you just want to count the rows that contain at least one "X", try:
=SUMPRODUCT(--(B:B&C:C={"X";"XX"}))
This would simply concatenate columns B&C and then check if the resulting value is either "X" or "XX". Depending if you do not even have headers it can be even simpler:
=SUMPRODUCT(--(B:B&C:C<>""))
If you want te minus the header: =SUMPRODUCT(--(B:B&C:C<>""))-1
Use concat formula in column D such that D1=CONCAT(A1,B1) , D2=CONCAT(A2,B2) and so on.
D1=CONCAT(A1,B1)
Then use counta function on column D to count all cells that are not blank, simple as that , i hope.
=COUNTA(D:D)
Does that help you ?
OR Alternatively Try,
= COUNTIFS(B:B, "X",C:C, "") + COUNTIFS(B:B, "",C:C, "X") + COUNTIFS(B:B, "X",C:C, "X")
If you have Excel365 then can use FILTER() function with COUNTA().
=COUNTA(FILTER(A1:A4,(B1:B4="x")+(C1:C4="x")))
See if below implementation of SUMPRODUCT is useful for you.
=SUMPRODUCT(--ISNUMBER(SEARCH("X",B2:B5&C2:C5,1)))
Or it needs to be tight and avoid issues like wild card matches etc. then you can also try:
=SUMPRODUCT(--(((B2:B5="X")+(C2:C5="X"))>0))
I am trying to exclude text from arrays in a SUMPRODUCT function.
The formula I am using is:
=SUMPRODUCT(--ISNUMBER(FIND("S",Schedule!$AT$14:$DP$100)),(Schedule!$AT12:DP12>=D29)*(Schedule!AT12:DP12<=E29)*(Schedule!$A14:A100="VP")*((Schedule!$AT$14:$DP$100)))
Schedule!$AT$14:$DP$100: contains numbers and S (or s)
Schedule!$AT12:DP12: contains dates
D29 contains a date
Schedule!AT12:DP12: contains dates
E29 contains a date
Schedule!$A14:A100: contains various text of which I only want lines with VP in them included.
If I change Schedule!$AT$14:$DP$100 to Schedule!$AT$14:$DO$100 then it works, so I know if is the S in the cell that creates the error. I know I can't multiply an number by an S.
I also tried:
=SUMPRODUCT(--SUBSTITUTE(Schedule!$AT$14:$DP$100,"S",0),(Schedule!$AT12:DP12>=D29)*(Schedule!AT12:DP12<=E29)*(Schedule!$A14:A100="VP")*((Schedule!$AT$14:$DP$100)))
I also tried, but to no avail.
=SUMPRODUCT(SUBSTITUTE(Schedule!$AT$14:$DP$100,"S",0)*(Schedule!$AT12:DP12>=D29)*(Schedule!AT12:DP12<=E29)*(Schedule!$A14:A100="VP")*((Schedule!$AT$14:$DP$100)))
=SUMPRODUCT(SUBSTITUTE(Schedule!$AT$14:$DP$100,"S",0)*(Schedule!$AT12:DP12>=D29)*(Schedule!AT12:DP12<=E29)*(Schedule!$A14:A100="VP"))
Basically what I am trying to say is:
If the cell is in a date range and has VP in the line then add up the cells in the range AT14:DP100 on the Schedule Sheet. So it will be the sum of [number x 1(true) x 1(true) x 1(true)] + [number x 0(false) x 1(true) x 1(true)]...
Where am I going wrong? I feel I may need to use an array formula (CTRL SHIFT and ENTER)
Due to the number of functions that won't automatically operate as Arrays in a SUMPRODUCT, you probably need to use an Array Formula. (i.e. use Ctrl + Shift + Enter)
Fortunately, you're already done all the heavy lifting involved. All we're going to do is re-write your current SUMPRODUCT(<Condition>,<Values>) as {SUM(IF(<Condition>,<Values>,0))}:
{=SUM(IF(ISNUMBER(FIND("S",Schedule!$AT$14:$DP$100)),(Schedule!$AT12:DP12>=D29)*(Schedule!AT12:DP12<=E29)*(Schedule!$A14:A100="VP")*((Schedule!$AT$14:$DP$100)),0))}
I have multiple columns as follows
A B C D Outcome
Y Y
N N
N N
Y Y
My outcome is in the column E. If the cell is filled, I want to see it in the outcome column. If not I want to see a blank cell. I tried my best, but I could do it. Is there a simple function to do it. Thanks for your help.
There are a number of ways to accomplish this. One would be:
// Copy this down
In Cell E2: =IF(COUNTA(A2:D2)=0,"",CONCATENATE(A2,B2,C2,D2))
Try :
=A2&B2&C2&D2
I need to do a match/index search in reverse right to left
each cell with have an x i need do go from right to left find what column the x is in and report the position so can then go to the top of that column and pull that data. I basically need to find out what column is the last X in.
A B C D E F G H I J
State 27-Aug 28-Aug 29-Aug 30-Aug 31-Aug 1-Sep 2-Sep 3-Sep 4-Sep
VI X X X X X X
in above example 3 rows 10 columns if i want to see that the last X is in Column G(7) then i use the index to go to that column(7), row A to 1-sep as the answer.
This will find the last cell with a value, regardless of value:
=INDEX($A$1:$J$1,MATCH("zzz",A2:J2))
If you want to find the last X, regardless of what is or is not in any of the other cells, then use this formula:
=INDEX($A$1:$J$1,AGGREGATE(14,6,COLUMN(A2:J2)/(A2:J2="X"),1))
One note: this is an array type formula and will be slower than the prior formula. If you only have one it will not make a difference. If you have hundreds you will see a difference.
But if you have other text strings after the X and you want the X then it is the way to go.
try out
=INDEX(1:1,1,COUNTIF(2:2,"X")-1)
Assuming there are no gaps within the stream of X's
=MATCH(2,IF(A2:J2="x",1,FALSE))
This is an array formula.
This will give you last position of x. Then, like you indicated, put the result inside INDEX function and you should be good. I like this option because i can put any condition inside the if statement, like >0.
I am trying to get a formula that will work for the following:
if Cell A contains X, then Cell B = Cell C +1, but if Cell A contains Y, then Cell B = Cell C +2, but if Cell A contains Z then Cell B = Cell C +3
any help greatly appreciated
You may be able to use SWITCH :
https://support.office.com/en-us/article/SWITCH-function-47ab33c0-28ce-4530-8a45-d532ec4aa25e
A simple IF statement can be written as below...
=IF(A2="X",C2+1,IF(A2="Y",C2+2,IF(A2="Z",C2+3,"")))
There are various other approaches to get the desired output. One of them is like below...
=IFERROR(CHOOSE(MATCH(A2,{"X","Y","Z"},0),C2+1,C2+2,C2+3),"")
Consider:
=LOOKUP(A1,{"X","Y","Z"},{1,2,3})+C1
EDIT#1:
To use LOOKUP(), the input vector must be in alphabetic order.