Count upon some conditions

Gildasl

New Member
Joined
Mar 29, 2012
Messages
22
Hi,

I need to count the number of days that at least one red umbrella is sold and group them between 2 dates (every 2 weeks).
In the case below:
1 day at least some umbrella have been sold between 6/15/2011 and 6/30/2001
2 days at least some umbrella have been sold between 8/1/2011 and 8/15/2011.

Thanks,
Gildas


<table border="0" cellpadding="0" cellspacing="0" width="358"><colgroup><col style="mso-width-source:userset;mso-width-alt:5595;width:115pt" width="153"> <col style="mso-width-source:userset;mso-width-alt:7497;width:154pt" width="205"> </colgroup><tbody><tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt;width:115pt" height="20" width="153">Creation date</td> <td class="xl66" style="width:154pt" width="205">Number of sales of Red umbrella</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt" height="20" align="right">6/28/2011</td> <td class="xl66">
</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt" height="20" align="right">6/28/2011</td> <td class="xl66" align="right">93</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt" height="20" align="right">7/8/2011</td> <td class="xl66">
</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt" height="20" align="right">7/21/2011</td> <td class="xl66">
</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt" height="20" align="right">8/2/2011</td> <td class="xl66">
</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt" height="20" align="right">8/4/2011</td> <td class="xl66" align="right">5</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt" height="20" align="right">8/5/2011</td> <td class="xl66" align="right">2</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt" height="20" align="right">8/5/2011</td> <td class="xl66">
</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt" height="20" align="right">8/8/2011</td> <td class="xl66">
</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt" height="20" align="right">8/10/2011</td> <td class="xl66">
</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt" height="20" align="right">8/15/2011</td> <td class="xl66" align="right">120</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt" height="20" align="right">8/16/2011</td> <td class="xl66">
</td> </tr> <tr style="height:15.0pt" height="20"> <td class="xl65" style="height:15.0pt" height="20" align="right">8/16/2011</td> <td class="xl66">
</td> </tr> </tbody></table>
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
try something like this, if the cells are formatted right this should work, note you can also change the date for a cell if you wanted to make it easier ie SUMPRODUCT(--((A2:A14)>D1..... etc


SUMPRODUCT(--((A2:A14)>6/15/2011),--((A2:A14)<6/30/2011),--(B2:B14>0))
 
Upvote 0
@ jono19872006
Your proposal do not work because the array arguments do not have the same dimensions (according to Excell help).

BTW, why is the meaning of the sign --?

Thanks,
Gildas
 
Upvote 0
Try this.

<?XML:NAMESPACE PREFIX = D1),$B$2 /><D1),$B$2:$B$14)< u>sorry my posts keep cuttinf off the formula</D1),$B$2:$B$14)<>
<D1),$B$2:$B$14)< u>
Code:
</D1),$B$2:$B$14)<>
<D1),$B$2:$B$14)< u>'=SUMPRODUCT(--(($A$2:$A$14)>C1),--(($A$2:$A$14)<D1),$B$2:$B$14)< D1),$B$2:$B$14)<>
<D1),$B$2:$B$14)< u>
</D1),$B$2:$B$14)<>
<D1),$B$2:$B$14)< u>Ignore this post. formula gets cut off past the > sign</D1),$B$2:$B$14)<>
</D1),$B$2:$B$14)<></D1),$B$2:$B$14)<>
 
Last edited:
Upvote 0
Use jono19872006 formula just get rid of ,--(B2:B14)>0
it will count the number of true matches.
 
Last edited:
Upvote 0
Hi,

I need to count the number of days that at least one red umbrella is sold and group them between 2 dates (every 2 weeks).
In the case below:
1 day at least some umbrella have been sold between 6/15/2011 and 6/30/2001
2 days at least some umbrella have been sold between 8/1/2011 and 8/15/2011.

Thanks,
Gildas


<TABLE cellSpacing=0 cellPadding=0 width=358 border=0><COLGROUP><COL style="WIDTH: 115pt; mso-width-source: userset; mso-width-alt: 5595" width=153><COL style="WIDTH: 154pt; mso-width-source: userset; mso-width-alt: 7497" width=205></COLGROUP><TBODY><TR style="HEIGHT: 15pt" height=20><TD class=xl65 style="WIDTH: 115pt; HEIGHT: 15pt" width=153 height=20>Creation date</TD><TD class=xl66 style="WIDTH: 154pt" width=205>Number of sales of Red umbrella</TD></TR><TR style="HEIGHT: 15pt" height=20><TD class=xl65 style="HEIGHT: 15pt" align=right height=20>6/28/2011</TD><TD class=xl66>

</TD></TR><TR style="HEIGHT: 15pt" height=20><TD class=xl65 style="HEIGHT: 15pt" align=right height=20>6/28/2011</TD><TD class=xl66 align=right>93</TD></TR><TR style="HEIGHT: 15pt" height=20><TD class=xl65 style="HEIGHT: 15pt" align=right height=20>7/8/2011</TD><TD class=xl66>

</TD></TR><TR style="HEIGHT: 15pt" height=20><TD class=xl65 style="HEIGHT: 15pt" align=right height=20>7/21/2011</TD><TD class=xl66>

</TD></TR><TR style="HEIGHT: 15pt" height=20><TD class=xl65 style="HEIGHT: 15pt" align=right height=20>8/2/2011</TD><TD class=xl66>

</TD></TR><TR style="HEIGHT: 15pt" height=20><TD class=xl65 style="HEIGHT: 15pt" align=right height=20>8/4/2011</TD><TD class=xl66 align=right>5</TD></TR><TR style="HEIGHT: 15pt" height=20><TD class=xl65 style="HEIGHT: 15pt" align=right height=20>8/5/2011</TD><TD class=xl66 align=right>2</TD></TR><TR style="HEIGHT: 15pt" height=20><TD class=xl65 style="HEIGHT: 15pt" align=right height=20>8/5/2011</TD><TD class=xl66>

</TD></TR><TR style="HEIGHT: 15pt" height=20><TD class=xl65 style="HEIGHT: 15pt" align=right height=20>8/8/2011</TD><TD class=xl66>

</TD></TR><TR style="HEIGHT: 15pt" height=20><TD class=xl65 style="HEIGHT: 15pt" align=right height=20>8/10/2011</TD><TD class=xl66>

</TD></TR><TR style="HEIGHT: 15pt" height=20><TD class=xl65 style="HEIGHT: 15pt" align=right height=20>8/15/2011</TD><TD class=xl66 align=right>120</TD></TR><TR style="HEIGHT: 15pt" height=20><TD class=xl65 style="HEIGHT: 15pt" align=right height=20>8/16/2011</TD><TD class=xl66>

</TD></TR><TR style="HEIGHT: 15pt" height=20><TD class=xl65 style="HEIGHT: 15pt" align=right height=20>8/16/2011</TD><TD class=xl66>

</TD></TR></TBODY></TABLE>
Try this...

Book1
ABCDEF
26/28/2011__6/15/20116/30/20111
36/28/201193_8/1/20118/15/20113
47/8/2011_____
57/21/2011_____
68/2/2011_____
78/4/20115____
88/5/20112____
98/5/2011_____
108/8/2011_____
118/10/2011_____
128/15/2011120____
138/16/2011_____
148/16/2011_____
Sheet1

One of these formulas entered in F2 and copied down...

If you're using Excel 2007 or later:

=COUNTIFS(A$2:A$14,">="&D2,A$2:A$14,"<="&E2,B$2:B$14,"<>")

This one will work in all versions of Excel:

=SUMPRODUCT(--(A$2:A$14>=D2),--(A$2:A$14<=E2),--(B$2:B$14<>""))
 
Upvote 0
=SUMPRODUCT(--(A$2:A$14>=D2),--(A$2:A$14<=E2),--(B$2:B$14<>"")) works fine.

BTW, I have not figured out yet the meaning of the -- sign. Ideas?
Thanks,
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,831
Members
452,946
Latest member
JoseDavid

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