Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-26-2015, 11:11 AM
676nova 676nova is offline Need help building COUNTIFS solution Mac OS X Need help building COUNTIFS solution Office for Mac 2011
Novice
Need help building COUNTIFS solution
 
Join Date: Feb 2015
Posts: 3
676nova is on a distinguished road
Default Need help building COUNTIFS solution

Column A = dates, Column C = text data (either blank, N, P, or C). I would like to count the number of occurrences where column A is a Saturday or Sunday *AND* when column C is not blank.

Col A Col C
1/10/15 P


1/31/15 C
3/1/15
4/3/15 N
4/4/15 P

In the example above, the answer would be 2 as row 1 and row 4 would meet both criteria
Reply With Quote
  #2  
Old 02-26-2015, 12:35 PM
Pecoflyer's Avatar
Pecoflyer Pecoflyer is offline Need help building COUNTIFS solution Windows 7 64bit Need help building COUNTIFS solution Office 2010 64bit
Expert
 
Join Date: Nov 2011
Location: Brussels Belgium
Posts: 2,779
Pecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant future
Default

Try
Code:
=SUMPRODUCT((WEEKDAY(A2:A6)>5)*(C2:C6<>""))
Adapt the ranges to your need but they MUST have the same length
__________________
Did you know you can thank someone who helped you? Click on the tiny scale in the right upper hand corner of your helper's post
Reply With Quote
  #3  
Old 02-26-2015, 12:45 PM
gebobs gebobs is offline Need help building COUNTIFS solution Windows 7 64bit Need help building COUNTIFS solution Office 2010 64bit
Expert
 
Join Date: Mar 2014
Location: Atlanta
Posts: 837
gebobs has a spectacular aura aboutgebobs has a spectacular aura about
Default

There's probably a better way but at first blush this is how I would do it:

Add another column with the formula =WEEKDAY(A1,2), copy it down the sheet. Then your formula is:

Code:
=COUNTIFS(D:D,">5",C:C,"<>"&"")
or

Code:
=SUMPRODUCT((D:D>5)*(C:C<>""))
Reply With Quote
  #4  
Old 02-26-2015, 12:45 PM
gebobs gebobs is offline Need help building COUNTIFS solution Windows 7 64bit Need help building COUNTIFS solution Office 2010 64bit
Expert
 
Join Date: Mar 2014
Location: Atlanta
Posts: 837
gebobs has a spectacular aura aboutgebobs has a spectacular aura about
Default

Yep...I knew there was a better way. :-)
Reply With Quote
  #5  
Old 02-26-2015, 12:47 PM
gebobs gebobs is offline Need help building COUNTIFS solution Windows 7 64bit Need help building COUNTIFS solution Office 2010 64bit
Expert
 
Join Date: Mar 2014
Location: Atlanta
Posts: 837
gebobs has a spectacular aura aboutgebobs has a spectacular aura about
Default

Quote:
Originally Posted by 676nova View Post
In the example above, the answer would be 2 as row 1 and row 4 would meet both criteria
Row 5 too, right?
Reply With Quote
  #6  
Old 02-26-2015, 01:12 PM
676nova 676nova is offline Need help building COUNTIFS solution Mac OS X Need help building COUNTIFS solution Office for Mac 2011
Novice
Need help building COUNTIFS solution
 
Join Date: Feb 2015
Posts: 3
676nova is on a distinguished road
Default

This worked - thanks! Not that I am asking anyone to look at this further, but I am still frustrated that the WEEKDAY function behaves so badly within the COUNTIFS and SUMPRODUCT formulas. The initial suggestion using SUMPRODUCT did not give the correct answer, I had been trying many different approaches to get SUMPRODUCT or COUNTIFS to work using WEEKDAYS as criteria.
Reply With Quote
  #7  
Old 02-26-2015, 01:41 PM
gebobs gebobs is offline Need help building COUNTIFS solution Windows 7 64bit Need help building COUNTIFS solution Office 2010 64bit
Expert
 
Join Date: Mar 2014
Location: Atlanta
Posts: 837
gebobs has a spectacular aura aboutgebobs has a spectacular aura about
Default

Quote:
Originally Posted by 676nova View Post
The initial suggestion using SUMPRODUCT did not give the correct answer
You mean Peco's formula? I tried it and it worked fine. The answer for the data given is 3.
Reply With Quote
  #8  
Old 02-26-2015, 02:45 PM
676nova 676nova is offline Need help building COUNTIFS solution Mac OS X Need help building COUNTIFS solution Office for Mac 2011
Novice
Need help building COUNTIFS solution
 
Join Date: Feb 2015
Posts: 3
676nova is on a distinguished road
Default

Ah! Peco's did work, of course! I needed to modify the arguments to "WEEKDAY(A2:A6,2)" for it to work correctly in the actual spreadsheet where I want to use this. I can't explain why, but there is something about SUMPRODUCT that confuses my. I think it has to do with using "*" in the equation to "multiply" things when you are actually not performing any multiplication. In any event, THANKS to everyone for such fast responses. I have loved Excel since it first came out, and it seems there is very little it can't do
Reply With Quote
  #9  
Old 02-26-2015, 03:04 PM
gebobs gebobs is offline Need help building COUNTIFS solution Windows 7 64bit Need help building COUNTIFS solution Office 2010 64bit
Expert
 
Join Date: Mar 2014
Location: Atlanta
Posts: 837
gebobs has a spectacular aura aboutgebobs has a spectacular aura about
Default

Quote:
Originally Posted by 676nova View Post
I can't explain why, but there is something about SUMPRODUCT that confuses my. I think it has to do with using "*" in the equation to "multiply" things when you are actually not performing any multiplication.
Actually, it does do multiplication. It sums the multiplications done between the arrays specified.

But that raises something that I am confused about and maybe Peco can explain it. As explained by Microsoft, the arrays are supposed to be separated by commas. Sometimes I have to separate them with asterisks, as you say, or it doesn't work. Sometimes I have to use commas. Sometimes I have to use a comma here and an asterisk there.

Anyhoo, there seems to be an explanation here but I will have to read it later. Gotta hit the dusty trail.

http://www.mrexcel.com/forum/excel-q...-asterisk.html
Reply With Quote
  #10  
Old 02-27-2015, 12:50 PM
Pecoflyer's Avatar
Pecoflyer Pecoflyer is offline Need help building COUNTIFS solution Windows 7 64bit Need help building COUNTIFS solution Office 2010 64bit
Expert
 
Join Date: Nov 2011
Location: Brussels Belgium
Posts: 2,779
Pecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant future
Default

More info about SUMPRODUCT can be found at Bob Philips' site
__________________
Did you know you can thank someone who helped you? Click on the tiny scale in the right upper hand corner of your helper's post
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
COUNTIFS Help Needed OTPM Excel 2 04-09-2014 08:32 AM
Building blocks show correctly in dropdown, but wrong building block populates in doc wordgirl123 Word 0 10-03-2013 08:30 AM
Compound Countifs Query not working Lonercom Excel 5 06-28-2013 10:27 AM
Need help building COUNTIFS solution Countifs and Sumproduct Algo Excel 6 11-13-2012 07:44 AM
countifs? sonyaturpin Excel 1 05-23-2012 08:29 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:07 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft