Count B:H value based on column A value - excel

I want to count occurrences of a value X within a range (B1:H38) only if the column A value in that row is value Y.
I got close with the following, but it gives a #VALUE! Error and I don’t think it’s the right fit for what I need:
=COUNTIFS(A1:A38,“Y”,B1:H38,”X”)
What is the correct way to do this?
Edit 1:
Column A is either blank, or one of 5 words.
Columns B through H are either blank, words, or numbers.
In my mind, the logic is: find items in A that match “Y”, then check the rest of the row from B to H for “X”.
There may be 0, 1, or up to 7 matches in a given row.

u already done it right.. it just that you formula is for 1 (one) time count.. not repeated # every row .
=COUNTIFS(A1,“Y”,B1:H1,”X”)
put that in C1, then draq downwards. That should do.
Please share if it works/not/understandable. ( :

Related

Sequence Unique Values Within Another Unique Value in Excel

I am trying to create a formula that checks Column A for unique values, then takes that value and checks column B for unique values and orders them sequentially in Column C. Column C is the where the formula goes. It's not in the actual data set.
This is what I want my data set to look like.
For example, I want to find unique Entry Number "123-A. I then want to look within that entry number and find the unique codes in Column B and order them sequentially. The first two are the same, so they both are sequence 1. Then the third row as a new code, "Y09", so it will get sequence 2. Once the next unique entry number is identified, I want to reset the sequential count. Thanks!
So, the first thing we want to do is check if a number has already been allocated. Since there are 2 columns to check, we need to use INDEX MATCH with an Array Condition instead of just a VLOOKUP:
INDEX($C$1:$C1, MATCH(1, ($A$1:$A1=$A2)*($B$1:$B1=$B2), 0))
These formula are intended for cell C2 - notice how we left the second cell in each Range reference without the $ to lock it in place. This means it will always stop at the row above the formula
If this works, we're done. If it doesn't we get an error - so, we can use IFERROR:
=IFERROR(INDEX($C$1:$C1, MATCH(1, ($A$1:$A1=$A2)*($B$1:$B1=$B2), 0)), ???)
On to replacing those question marks!
Since we don't have a match, we need to find the largest match for the Entry Number, and add 1 for it. If you have Office365 or Office2019, we can just use the MAXIFS function. Otherwise, we will have to use SUMPRODUCT and MAX to get the same result: (If the Entry Number does not exist, this will return 0)
MAXIFS($C$1:$C1, $A$1:$A1, $A2)
SUMPRODUCT(MAX($C$1:$C1 * ($A$1:$A1=$A2)))
Then, Add 1:
=IFERROR(INDEX($C$1:$C1, MATCH(1, ($A$1:$A1=$A2)*($B$1:$B1=$B2), 0)), MAXIFS($C$1:$C1, $A$1:$A1, $A2) + 1)
=IFERROR(INDEX($C$1:$C1, MATCH(1, ($A$1:$A1=$A2)*($B$1:$B1=$B2), 0)), SUMPRODUCT(MAX($C$1:$C1 * ($A$1:$A1=$A2))) + 1)
It appears that your data is already organized/sorted by the column A and B values. If this is the case, we can construct a formula implementing the following rules:
if the adjacent A and B values match the values above them, copy down the C value from above
if the adjacent A value matches the value above it, but the B value does not, then increment the C value from above.
If the A value does not the value above it, then set the C value to 1
In C2 enter 1. In C3 enter:
=IF(AND(A3=A2,B3=B2),C2,IF(A3=A2,C2+1,1))
and copy downward:
if your data is not organized in the same way your picture indicates, then ignore this solution.

Trying to write an If statement that will show date of last item selected and change as updated

I have a series of data. That goes down the left side column of dates...
8/2, 8/3, and such. Then 2 columns over I have a column left for if the date is checks so 8/2:X, 8/3:X, 8/4: ,8/5: and such. I'm wanting to reference the date in the last field that has a X in it
A B C D
8/1 X
8/2 X
8/3 x
8/4
8/5
Trying to reference the date for the last A cell if there is an X in the D cell. So it would be for 8/3 would be the date. I'm not sure how to run with this.
I've looked through but now sure how to state an if statement
To return the date in column A that is in the same row as the last "X" (or "x") in column D:
=LOOKUP(2,1/(D:D="X"),A:A)
If you only want you cells to calculate if there's an X in column E you could write it like this:
=if(E3="x","", [put your calculation here] )
If you only care if there's anything there, not necessarily an "x" or if you're worried about case sensitivity:
=if(isblank(E3),"", [put your calculation here] )
Then just drag this formula down.
Based on what you had told me use the following formula in cell H1:
=maxifs($A$3:$A$24,$E$3:$E$24,"x")
If I understood correctly, you want to return the highest date with a X in it right? You can simulate a MAX IF with array formulas:
{=MAX(IF(E:E="X",A:A,FALSE))}
(You have to enter the formula with CTRL + SHIFT + ENTER to get those brackets and to it work properly)
The IF part inside that formula returns only a list of values (inside the TRUE part) that the condition returns true
Edit: If you're using Excel 2013 and above, you should check #Mark answer, as it is a cleaner way to do it
Just going to throw my hat in the ring here for a formula that will display the value of date that corresponds to the largest row number with an X in it in column D.
AGGREGATE will find the row number as follows:
=AGGREGATE(14,6,ROW(D:D)/(D:D="x"),1)
That can be nested inside an INDEX function to return the cell address of corresponding date which in turns display the value of the cell as follows:
=INDEX(A:A,AGGREGATE(14,6,ROW(D:D)/(D:D="x"),1))
While the above does work, AGGREGATE is performing array operations. Therefore full column references like D:D should be avoided and reduced to a smaller range that would closer match your data in order to avoid excess calculations on blank cells.
If you can ONLY enter the X consecutively without skipping a date, for instance you would not mark 8/6 X if 8/5 has no X marked, then you can find the last date using the following formula:
=INDEX(Column_Date,COUNTIF(Column_X,"X"))
The look up is case insensitive which means you can also enter lowercase x instead of uppercase X in column D or mix them up, the formula will return the same result anyway.
The solution is using COUNTIF function to locate the position of the last X in Column E of your worksheet, and then use INDEX function to return the corresponding date in Column A.
COUNTIF is a combination of COUNT and IF function. I guess this might be the "IF" function you are after.
Please note if the X is not marked consecutively day by day, you may need to use someone else' answer.
Cheers :)

Difference between 2 values in a row in excel formula

How to get this in excel
excel table
F column is the result column
For the following answer I am going to assume you only ever have two numbers in any row, but they can be in any cell along the row and they are always greater than 0.
If you just wish to find the difference between the two numbers without worrying about which number is bigger, a simple equation using maximum and minimum can be used, eg in Cell F1 you would have
=MAX(A1:E1)-MIN(A1:E1)
However, from your example, it seems more likely that you want to know the difference between the first number and the second number.
The difficulty here, is that the cells in columns B, C and D could contain either the first number, the second number, or no number! The solution is to use the following equation in Cell F1
=(MAX(A1:E1)-MIN(A1:E1))*IF(MAX(A1:E1)=INDEX(A1:E1,MATCH(0,A1:E1,-1)),-1,1)
This formula works as follows:
We still start off with the simple difference between the max and min, and then this is multiplied by 1 or -1 depending on which way around the numbers are.
MATCH(0,A1:E1,-1)
This part of the equation looks along the row for a 0, and assumes they are in descending order, so it will return the position of the second number.
This is then inserted into the INDEX function and checked to see if it is the same as the maximum number and the IF function returns either -1 or 1 as required.
Paste this formula on F1, then copy to F2 and F3
=INDEX(A1:E1,MATCH(TRUE,INDEX(A1:E1<>"",),0)) - LOOKUP(9.99E+307,A1:E1)

Excel Formula with IF... ELSE

Hi all,
I have this excel where by I need to find the location of the item if they are found in column B.
So In my F column, I tried to write ifelse formula which didnt work.which is
=IF(D2="NULL","NONE",C((D2))).
My idea is if D2 is not null, use the value in D column to find the location in C column. In this example, fish no 4, so it is found, my F column should show the value "C" using the value shown in D column and use it as Row no in C column
I hope you guys get the idea and help me out a newbie in excel. Thanks in advance
=vlookup($D2,$A$2:$C$6,3,0)
you can use that in column F. Place that formula in F2 and copy down.
you could technically use it in column E as well, but you would need to change the 3 to a 2.
you did not say what you wanted to do if the D value was "Null" so I am going to take a stab at the dark and wrap you lookup formula in an if statement that will deal with "Null" or empty cells
=IF(OR($D2="NULL",$D2=""),"",VLOOKUP($D2,$A$2:$C$6,3,0))
That is the alternative formula to place in F2 and copy down.
Use the formula:
=IF(D2<>"NULL",VLOOKUP(D2,A2:C6,3,FALSE),"Value is NULL")
Here is the working example:
Put formula in cell F2 and drag it down.
[edit]to pull proper location column, not just the row #[/edit]
Seems like a job for MATCH+OFFSET
Try this formula in cell F2:
=OFFSET($C$1, MATCH(E2,B:B,0)-1, 0, 1, 1)
Match is used to locate the value in the first argument (ie E2) within the range specified in 2nd argument (ie B:B). I use B:B but you could also use range B2:B30 or whatever more specific range you want. (I prefer the more generic B:B, though :) )
Third paramter "0" just indicates "Exact match".
This function will retun "#N/A" if nothing found.
OFFSET takes the result from MATCH to pick out the Location you want. The first parameter in OFFSET is the rows below (or above if negative) from the base row (in this case $C$1). the next is the column: 0 since we're in the column we want to be in. The last two are the size of the range: 1,1 is a 1x1 cell, so just 1 cell. If we did ...,2,3), that would be 2 rows high and 3 columns wide - or a 6 cell range. We're just after 1 cell here.
I've always preferred MATCH + OFFSET to other options, I just found they held up more robustly to changes in a sheet (ie new rows/columns added). So it's mostly personaly preference over VLOOKUP and INDEX. I honestly have never compared their actual performance, however, I've never had any issues with MATCH+OFFSET running slowly :)

Compare two sheets as matrix table

A1:200 B1:260
A2:300 B2:220
A3:400 B3:240
A4:200 B4:300
A5:200 B5:200
I got two tables going on and basically I want to check if row A is greater than 200 AND row B is greater than 250 then count.
So far I have this:
=COUNTIF(A1:A5,">= 200")
but I have no idea how to check if A passes then check B and if so, count it. I'm guessing something to do with IF, AND and maybe a for loop? I'm not familiar with this language at all :x
You want to calculate total count when column A is greater than 200 and B contains cell values greater than 250.
If you want a single value for entire table use countifs,
=COUNTIFS($A$1:$A$5,">200",$B$1:$B$5,">250")
If you want to get the counts in different column (let say C) on each row, then copy and paste below formula in C1 and drag it to C5 cell
=+IF(AND(A1>200,B1>250),1,0)
Where 1 means both conditions are true and 0 means either of condition is false.
However if you want to check first if the first condition is satisfying or not, then you can use below formula:
=+IF(A1>200,IF(B1>250,1,0),2)
Where "1" means true and both the condtion is satisfying , "0" means first condition is satisfying but second is not and "2" means the first condition is not satisfying hence it didn't check the second condition.
Hope this helps

Resources