Excel SUM and IF combine help - excel

I have two columns of numbers. Both are 1 to 5. I want to count all the cells where the left column value equals the right column value AND the left column value equals a certain value.
I tried this:
=SUM(IF(W2:W13=X2:X13 AND W2:W13=4,1,0))
I've tried pressing Ctrl+Shift+Enter and it adds {} around the formula but that didn't help either.
I think it's the W2:W13 = 4 part that doesn't work

=COUNTIFS(W2:W13,"=4", X2:X13, "=4")

You can use the sumif() function:
SumIf( range, criteria, sum_range )
it will apply the criteria for each row in the range.
Edit: to count the matches, you can use sum_range = 1 or use the Countif() function suggested by Ben in his answer

Have you considered a third column (C) with the formula IF(A1=B1,1,0) and then summing that third column?

I'm not much of an Excel Expert, but didn't they craeted the COUNTIF(range, criteria) function for this?

Add a third column eg Z2:Z13 with this formula: IF(AND(W2=X2; W2=4); 1; 0)
Then sum that one.

I don't have Excel 2007. So here's how you can do it in Excel 2003:
=COUNT(IF((W2:W14=4)*(X2:X14=4),Y2:Y14))
Since you are looking for a specific value and the column next to it to be the same value, you can just compare both columns to the same value.
The trick to get this to work is after entering the formula you need to hit F2 to go into edit mode and then hit CTRL-SHIFT-ENTER which makes this formula an array formula. This will put {} around the entire formula. Without making this an array formula this formula won't work.
I found this information in the Excel help document titled Count how often a value occurs

Related

Lookup excel return min value if no match found

If number from first coulmn is found in the second column, it should return that number.
If number from first coulmn is not found in the secound column, it should return closest possible min value
You can use vlookup() like this, BUT you need to sort the values:
In C1 enter the array formula:
=MAX(IF(B:B<=A1,B:B))
and copy downward:
Array formulas must be entered with Ctrl + Shift + Enter rather than just the Enter key. If this is done correctly, the formula will appear with curly braces around it in the Formula Bar.
NOTE:
Sorting is not required.
Array entry is not required if you are using Excel 365.
Another option is SUMPRODUCT:
=SUMPRODUCT(MAX(--($B$1:$B$12<=A1)*$B$1:$B$12))
It works on Excel 2007 or higher, no need of array entered formula and no need of sorting.

Incrementing excel formula by two

I have an excel sheet with the following formula:
=('Forecast Workings'!T2+'Forecast Workings'!T3)/1000-4.6
=('Forecast Workings'!T4+'Forecast Workings'!T5)/1000-4.6
=('Forecast Workings'!T6+'Forecast Workings'!T7)/1000-4.6
How can I write this formula so that I can simply drag this down to fill in the rest of the values and that I get the value to increment by 2 each time?
If your initial cell is in first row and you want to multiply you could use:
=(INDIRECT("Forecast Workings!T"&ROW()*2)+INDIRECT("Forecast Workings!T"&ROW()*2+1))/1000-4.6
Subtract value from ROW() if you are not in the first row.
try,
=sum(index('Forecast Workings'!T:T, (row(1:1)-1)*2+2),
index('Forecast Workings'!T:T, (row(1:1)-1)*2+3))/1000-4.6
You will need a helper column, or use indirect and then use a mathematical approach on the formula row() to get the right return. as an example if you start this in row 2 and drag down this will increment by two. (assuming row one are titles)
=INDIRECT("'Forecast Workings'!T" & (ROW()-1)*2)+INDIRECT("'Forecast Workings'!T" & ((ROW()-1)*2)+1)/1000-4.6
I would also advise to check out the code of conduct, you would need to show what you have tried to solve this yourself and what did not work.

Excel: find the Max of an array with same names

I have searched the Net and tried multiple solution which never worked. You are my last hope.
I have a table like that:
NAMES.......... VALUES
A...........................4
A...........................1
B...........................4
B...........................3
B...........................2
B...........................1
C...........................4
C...........................3
As you can see, the first column has names only where the second one values.
Both Names and Values often repeat them self.
The idea is to TAG the names (first column) with the MIN value taken from the second column.
So the correct result should be:
NAMES.......... VALUES
A...........................1
B...........................1
C...........................3
I am trying to do that through Excel using the INDEX+Match formula where I am trying to add a MIN formula without success:
=MIN(INDEX($D$25:$D$36,MATCH(C25,$C$25:$C$36,0),1))
I have put the MIN everywhere but none seems to work. Which is the correct syntax and if this is not the right solution, which formula might do the job?
Thank you for your time and help
With data in column A and B, in C1 through C3 enter:ABC then in D1 enter the array formula:
=MIN(IF(A$1:A$100=C1,B$1:B$100,""))
and copy down:
Array formulas must be entered with Ctrl + Shift + Enter rather than just the Enter key. If this is done correctly, the formula will appear with curly braces around it in the Formula Bar.
If the data never changes, a Pivot Table is easier to implement.
Two non-array alternatives.
With the newer MINIFS function.
=minifs(d:d, c:c, c25)
Using INDEX in its array format but entered as a standard formula,
=min(index((d$25:d$36)+(c$25:c$36<>c25)*1e99, , ))

Excel CountIf Formula With OR

I was looking for a excel formula to do a task. Tried using Countif,Countifs. But with no luck. Any help is appreciated.
Task as below.
Type--------------Primary Color--------------Secondary Color
Car----------------Blue--------------------------Red
Bike--------------Black-------------------------White
Car---------------Blue--------------------------Blue
I need a formula which gives me a count of Cars having blue as their colour(Either Primary Or Secondary)
You can use following array formula (confirmed with Ctrl+Shift+Enter to calculate count of blue cars:
=SUM(N((B2:B4="Blue")+(C2:C4="Blue")>0)*(A2:A4="Car"))
or non array version:
=SUMPRODUCT(N((B2:B4="Blue")+(C2:C4="Blue")>0)*(A2:A4="Car"))
This part:
(B2:B4="Blue")+(C2:C4="Blue")>0
is an alternative way of expressing OR (not suitable for array formulas as it always returns a single value). N function converts boolean values to 0 and 1.
Edit: updated the formulas to include condition for A column.
What about adding a column with the following
=IF(OR(B1="Blue", C1="Blue"), 1, 0)
and copy that down.
On another sheet you can sum that new entire column with
=SUM(D:D)
Of course you will have a worksheet reference to the other sheet attached to the SUM formula.
If you don't want to do an array formula you can just do 2 countifs formulas (which are easier for people to read than array formulas)
=COUNTIFS(b8:b12,"Blue")+COUNTIFS(c8:c12,"Blue")

Combine if statement & countif

I have a situation where I need to calculate ontime vs. late in a range of cells.
I use the if statement =IF(N2>K2 +30,"Late","") and this works fine however I would like to combine the countif statement to count the range of cells that contain "late"
Thanks
Try this:
=SUM(IF(N:N>K2+30,1,0))
Enter it as array formula by pressing CTRL+SHIFT+ENTER.
updated if you only need to count the number of lates.
As per Roberto's comment, if you are actually using a formula to put "Late" in column L for each relevant row you can use a simple COUNTIF to count those
=COUNTIF(L:L,"Late")
or if you want to use the source data in column N just use COUNTIF with that
=COUNTIF(N:N,">"&K2+30)

Resources