Count unique for each individual day

domtrump

Board Regular
Joined
Apr 1, 2010
Messages
245
I have a power pivot report that lists all the occupied room numbers for a hotel for each day. More than one person can share a room, so room numbers can be duplicated in any given day. I can use DISTINCTCOUNT in a measure and this works fine if I want to look at each individual day. However, when I want to do my count for the entire month, I of course just get a unique count of rooms for the month. I need a measure that will count the unique room numbers for each DAY and then all up all of the days to give me a MONTH total. Can someone help me out with the DAX syntax? Thanks.


My data looks like this:

Excel Workbook
BCDEF
3DateMonthRm Number*Unique Rooms
41-Jan11205**
51-Jan11205**
61-Jan11310*2
72-Jan11205**
82-Jan11310*2
9****
10****
11January1**4
12*****
Sheet1


In this example, there were two unique rooms for each day resulting in a monthly total of 4 rooms.
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
I think either of these will do what you want, adding up the number of distinct Rm Numbers on each date. I think the first one should perform better.
(I've just put dummy table names)

Code:
=
SUMX (
    VALUES ( [COLOR=#ff0000][B]DateTable[/B][/COLOR][Date] ),
    CALCULATE ( DISTINCTCOUNT ( [COLOR=#ff0000][B]FactTable[/B][/COLOR][Rm Number] ) )
)

Code:
=
COUNTROWS ( SUMMARIZE ( FactTable, [COLOR=#ff0000][B]DateTable[/B][/COLOR][Date], [B][COLOR=#ff0000]FactTable[/COLOR][/B][Rm Number] ) )
 
Upvote 0

Forum statistics

Threads
1,224,146
Messages
6,176,667
Members
452,740
Latest member
CoelhoVermelho

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