using countifs for comparing columns

TheGod1

New Member
Joined
Mar 19, 2014
Messages
8
Hello Everyone,
I am in a bit of a pickle. Before I came here to post a thread - I did some research and could not find a solution using COUNTIFS ; the closest I have come to is using 'sumproduct' which in my excel spreadsheet for some reason it is not working.

Basically what I have is an excel spreadsheet with a few columns - but for this forum I will simplify it and provide a smaller example.

COMPLETEDTRIAL REQUESTEDTRIAL COMPLETED
Y10-OCT-201420-OCT-2014

<tbody>
</tbody>

Above is a simplified version of the table of what I am using.
Basically I am trying to create a formula that says if Column B (trial requested) > column C (trial completed) then it needs to return a +1 for count.
I have tried the following:
=COUNTIFS(A:A,"Y",B:B>C:C)

The second part of the above formula does not work. I was wondering if anyone had a way to fix this using the countifs method. I have tried the SUMPRODUCT method already [sumproduct(--....,--.....)] etc, but for some reason it just doesn't work with my spreadsheet - maybe it's because I have about 8 different "criteria" that I am using?

Any help would be very much appreciated.
P.S Hope you all had a great Halloween!
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Try...

Code:
=SUMPRODUCT(--(A2:A100="Y"),--(B2:B100>C2:C100))

or

Code:
=SUM(IF(A2:A100="Y",IF(B2:B100>C2:C100,1)))

...confirmed with CONTROL+SHIFT+ENTER.

Adjust the ranges, accordingly.
 
Upvote 0
Try...

Code:
=SUMPRODUCT(--(A2:A100="Y"),--(B2:B100>C2:C100))

or

Code:
=SUM(IF(A2:A100="Y",IF(B2:B100>C2:C100,1)))

...confirmed with CONTROL+SHIFT+ENTER.

Adjust the ranges, accordingly.

1) First off, thanks so much for your reply Domenic. Much appreciated.
2)As previously mentioned - i was able to get the SUMPRODUCT to work on my 'small sample' spreadsheets where I was trying out formulas. But on the actual spreadsheet itself the sumproduct formula would not work.
3) Is it possible to use the COUNTIFS statement, or will I end up having to either find a fix for why my sumproduct formula is not working?
4) Is it possible to use continuous nested 'if' statements like your second example? (note: In my real spreadsheet, I would have to use about 7 "ifs" if this is the case.

Thanks in advance!
 
Upvote 0
You say that on your actual worksheet SUMPRODUCT does not work. Does it return an error? If so, which error? Can you post the exact formula that you tried?

You also say that you'll have to use 7 conditions. Can you describe those conditions?
 
Upvote 0
If the sumproduct wont work on the real data, are all your dates actually dates, and not text that looks like a date?

Try a test with just the 1st part, and then with just the 2nd part
 
Upvote 0
If the sumproduct wont work on the real data, are all your dates actually dates, and not text that looks like a date?

Try a test with just the 1st part, and then with just the 2nd part

Wow, very good observation.
I didn't even notice this before!
There are in fact some columns in the '2nd column of dates' that has some text in it instead of dates.
Is there anything that can be done to modify the formula?
But I've also noticed that the previous criteria in the SUMPRODUCT formula already removes all rows that would be non-dated (in the actual formula on my spreadsheet). Or does EXCEL not process it from left to right and remove any necessary rows one at a time?
 
Upvote 0
You say that on your actual worksheet SUMPRODUCT does not work. Does it return an error? If so, which error? Can you post the exact formula that you tried?

You also say that you'll have to use 7 conditions. Can you describe those conditions?

It returns a '0'.

The exact formula is below:
Code:
=SUMPRODUCT(--(($AC$7&"!A:A"="Offshore")+($AC$7&"!A:A"="Offshore/Domestic")),--($AC$7&"!B:B"=$M$3),--($AC$7&"!T:T"="06"),--($AC$7&"!E:E"="Y"),--($AC$7&"!J:J">$AC$7&"!K:K"))
 
Upvote 0
@ Ford

Nice catch!

@ TheGod1

First, I would convert those dates into true date values. This way you won't have any problems in any other future calculations that you may need. Here's how to do it quickly...

1) Select the whole column.

2) On the Ribbon, select Data > Text to Columns > Next > Next > under Column Data Format select Date > in the drop down arrow select "DMY" > Click Finish.

3) Do the same for any other column that contains dates formatted as text.

4) Then try the following formula...

Code:
=SUMPRODUCT(--ISNUMBER(MATCH(INDIRECT("'"&$AC$7&"'!A2:A100"),{"Offshore","Offshore/Domestic"},0)),--(INDIRECT("'"&$AC$7&"'!B2:B100")=$M$3),--(INDIRECT("'"&$AC$7&"'!T2:T100")="06"),--(INDIRECT("'"&$AC$7&"'!E2:E100")="Y"),--(INDIRECT("'"&$AC$7&"'!J2:J100")>INDIRECT("'"&$AC$7&"'!K2:K100")))

or

Code:
=SUM(IF(ISNUMBER(MATCH(INDIRECT("'"&$AC$7&"'!A2:A100"),{"Offshore","Offshore/Domestic"},0)),IF(INDIRECT("'"&$AC$7&"'!B2:B100")=$M$3,IF(INDIRECT("'"&$AC$7&"'!T2:T100")="06",IF(INDIRECT("'"&$AC$7&"'!E2:E100")="Y",IF(INDIRECT("'"&$AC$7&"'!J2:J100")>INDIRECT("'"&$AC$7&"'!K2:K100"),1))))))

...confirmed with CONTROL+SHIFT+ENTER.

Adjust the ranges, accordingly. Try to avoid whole column references, which can be resource intensive.

Hope this helps!
 
Last edited:
Upvote 0
@ Ford

Nice catch!

@ TheGod1

First, I would convert those dates into true date values. This way you won't have any problems in any other future calculations that you may need. Here's how to do it quickly...

1) Select the whole column.

2) On the Ribbon, select Data > Text to Columns > Next > Next > under Column Data Format select Date > in the drop down arrow select "DMY" > Click Finish.

3) Do the same for any other column that contains dates formatted as text.

4) Then try the following formula...

Code:
=SUMPRODUCT(--ISNUMBER(MATCH(INDIRECT("'"&$AC$7&"'!A2:A100"),{"Offshore","Offshore/Domestic"},0)),--(INDIRECT("'"&$AC$7&"'!B2:B100")=$M$3),--(INDIRECT("'"&$AC$7&"'!T2:T100")="06"),--(INDIRECT("'"&$AC$7&"'!E2:E100")="Y"),--(INDIRECT("'"&$AC$7&"'!J2:J100")>INDIRECT("'"&$AC$7&"'!K2:K100")))

or

Code:
=SUM(IF(ISNUMBER(MATCH(INDIRECT("'"&$AC$7&"'!A2:A100"),{"Offshore","Offshore/Domestic"},0)),IF(INDIRECT("'"&$AC$7&"'!B2:B100")=$M$3,IF(INDIRECT("'"&$AC$7&"'!T2:T100")="06",IF(INDIRECT("'"&$AC$7&"'!E2:E100")="Y",IF(INDIRECT("'"&$AC$7&"'!J2:J100")>INDIRECT("'"&$AC$7&"'!K2:K100"),1))))))

...confirmed with CONTROL+SHIFT+ENTER.

Adjust the ranges, accordingly. Try to avoid whole column references, which can be resource intensive.

Hope this helps!

Just wanted to say thank you both for your great tips.
I am going to shoot these ideas past my boss and see if he is willing to make some changes.
Your ideas have also got me thinking of some more ideas. Thanks so much!

GOOD NIGHT!

edit: I will post my final result if I get it to work. :)
 
Upvote 0

Forum statistics

Threads
1,216,144
Messages
6,129,120
Members
449,488
Latest member
qh017

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top