Counting Unique Number of Days

Smokeyham

Board Regular
Joined
Feb 1, 2006
Messages
120
Office Version
  1. 365
Platform
  1. Windows
I have a table with a large number of readings. Multiple readings are taken per day. I am trying to count the number of each week day on which we have taken readings, for instance "How many Saturdays have we been taking readings on."

I have the dates entered into Column A.

I tried the array formula =SUM(--(WEEKDAY(A1:A200)=7)) Where "7" represents Saturdays, but this gives me very high results. I suspect it is just counting all rows where the day is a Saturday.

Any suggestions?

Many thanks.

Gordon
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Something like this maybe


Excel 2010
ABCDE
1itemDateSales
2Item D19-Nov-17157
3Item B12-Nov-1724
4Item A13-Oct-1718
5Item D06-Oct-1720
6Item D11-Nov-1717
7Item C19-Nov-1719
8Item D26-Sep-1711
9Item D27-Nov-1721
10Item C03-Dec-1724
11Item B30-Nov-1724
12Item A29-Oct-1720
13Item C12-Nov-1715
14Item A06-Dec-1716
15Item C15-Oct-1724
16Item B02-Nov-1720
17Item C23-Sep-1717
18Item B23-Sep-1724
19Item C27-Oct-1718
20Item A01-Nov-1712
21Item D01-Nov-1720
22Item A24-Oct-1724
23Item D02-Dec-1714
24Item B05-Dec-1719
25Item A17-Nov-1723
26Item B17-Nov-1723
27Item B10-Nov-1711
28Item B05-Oct-1719
29Item B10-Dec-1713
30Item A18-Oct-1721
31Item C18-Oct-1714
32Item B24-Nov-1721
33Item C01-Dec-1723
34Item B01-Dec-1715
35Item A08-Oct-1722
36Item A18-Nov-1711
Sheet4
Cell Formulas
RangeFormula
E2=SUMPRODUCT((1/COUNTIF($B$2:$B$36,$B$2:$B$36))*(WEEKDAY($B$2:$B$36,2)=7))
 
Upvote 0
Something like this maybe

</p><br /><br /><table width="85%" cellpadding="2.5px" rules="all" style=";border: 2px solid black;border-collapse:collapse;padding: 0.4em;background-color: #FFFFFF" ><tr><td style="padding:6px" ><b>Worksheet Formulas</b><table cellpadding="2.5px" width="100%" rules="all" style="border: 1px solid;text-align:center;background-color: #FFFFFF;border-collapse: collapse; border-color: #BBB"><thead><tr style=" background-color: #DAE7F5;color: #161120"><th width="10px">Cell</th><th style="text-align:left;padding-left:5px;">Formula</th></tr></thead><tbody><tr><th width="10px" style=" background-color: #DAE7F5;color: #161120">E2</th><td style="text-align:left">=SUMPRODUCT(<font color="Blue">(<font color="Red">1/COUNTIF(<font color="Green">$B$2:$B$36,$B$2:$B$36</font>)</font>)*(<font color="Red">WEEKDAY(<font color="Green">$B$2:$B$36,2</font>)=7</font>)</font>)</td></tr></tbody></table></td></tr></table><br />

Thank you! That worked!

One interesting thing is that when I substitute the specified range (=SUMPRODUCT((1/COUNTIF($A$2:$A$349,$A$2:$A$349))*(WEEKDAY($A$2:$A$349,2)=T3))

with a named range (=SUMPRODUCT((1/COUNTIF(ObsCount[[#All],[Date]],ObsCount[[#All],[Date]]))*(WEEKDAY(ObsCount[[#All],[Date]],2)=T2))

I get a syntax error. The reference at the end of the equation (T2 or T3) is a reference to a cell with the day number.


Book1
TUV
1Day#DayNumber of Days
22Monday#VALUE!
33Tuesday7
44Wednesday8
55Thursday6
66Friday7
77Saturday4
81Sunday7
OccupancyRecords
Cell Formulas
RangeFormula
V2=SUMPRODUCT((1/COUNTIF(ObsCount[[#All],[Date]],ObsCount[[#All],[Date]]))*(WEEKDAY(ObsCount[[#All],[Date]],2)=T2))
V3=SUMPRODUCT((1/COUNTIF($A$2:$A$349,$A$2:$A$349))*(WEEKDAY($A$2:$A$349,2)=T3))
V4=SUMPRODUCT((1/COUNTIF($A$2:$A$349,$A$2:$A$349))*(WEEKDAY($A$2:$A$349,2)=T4))
V5=SUMPRODUCT((1/COUNTIF($A$2:$A$349,$A$2:$A$349))*(WEEKDAY($A$2:$A$349,2)=T5))
V6=SUMPRODUCT((1/COUNTIF($A$2:$A$349,$A$2:$A$349))*(WEEKDAY($A$2:$A$349,2)=T6))
V7=SUMPRODUCT((1/COUNTIF($A$2:$A$349,$A$2:$A$349))*(WEEKDAY($A$2:$A$349,2)=T7))
V8=SUMPRODUCT((1/COUNTIF($A$2:$A$349,$A$2:$A$349))*(WEEKDAY($A$2:$A$349,2)=T8))
 
Upvote 0
Thank you! That worked!

One interesting thing is that when I substitute the specified range (=SUMPRODUCT((1/COUNTIF($A$2:$A$349,$A$2:$A$349))*(WEEKDAY($A$2:$A$349,2)=T3))

with a named range (=SUMPRODUCT((1/COUNTIF(ObsCount[[#All],[Date]],ObsCount[[#All],[Date]]))*(WEEKDAY(ObsCount[[#All],[Date]],2)=T2))

I get a syntax error. The reference at the end of the equation (T2 or T3) is a reference to a cell with the day number.


Book1
TUV
1Day#DayNumber of Days
22Monday#VALUE!
33Tuesday7
44Wednesday8
55Thursday6
66Friday7
77Saturday4
81Sunday7
OccupancyRecords
Cell Formulas
RangeFormula
V2=SUMPRODUCT((1/COUNTIF(ObsCount[[#All],[Date]],ObsCount[[#All],[Date]]))*(WEEKDAY(ObsCount[[#All],[Date]],2)=T2))
V3=SUMPRODUCT((1/COUNTIF($A$2:$A$349,$A$2:$A$349))*(WEEKDAY($A$2:$A$349,2)=T3))
V4=SUMPRODUCT((1/COUNTIF($A$2:$A$349,$A$2:$A$349))*(WEEKDAY($A$2:$A$349,2)=T4))
V5=SUMPRODUCT((1/COUNTIF($A$2:$A$349,$A$2:$A$349))*(WEEKDAY($A$2:$A$349,2)=T5))
V6=SUMPRODUCT((1/COUNTIF($A$2:$A$349,$A$2:$A$349))*(WEEKDAY($A$2:$A$349,2)=T6))
V7=SUMPRODUCT((1/COUNTIF($A$2:$A$349,$A$2:$A$349))*(WEEKDAY($A$2:$A$349,2)=T7))
V8=SUMPRODUCT((1/COUNTIF($A$2:$A$349,$A$2:$A$349))*(WEEKDAY($A$2:$A$349,2)=T8))


Found the solution to the syntax error. If you run across this, just be sure to only choose data within your named column (not including the header row). Here is the updated version of the formula, which works.

=SUMPRODUCT((1/COUNTIF(ObsCount[Date],ObsCount[Date]))*(WEEKDAY(ObsCount[Date],2)=E17)). Notice the absence of "[#ALL]" in the formula.
 
Upvote 0

Forum statistics

Threads
1,213,543
Messages
6,114,236
Members
448,555
Latest member
RobertJones1986

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