Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
DAXHeadroom
Frequent Visitor

Distinct Count of Dates with Multiple Values

Greetings. 

Using the following table as an example, I am using two separate measures to make a Distinct Count of the Date column when the Hours column is = 0 (Measure 1) and when the Hours column > 0 (Measure 2). These two measures are subtotals and need to be displayed independently. However, I am overstating the total count by one because November 12 has values that are both = 0 and > 0. A given date should only be counted once. How can I ensure the output counts November 12 only once in these instances? 

 

Current output for Measure 1 = 2

Current output for Measure 2 = 3

Total = 5

 

Desired output for Measure 1 = 1

Desired output for Measure 2 = 3

Total = 4

 

IDDateHours
63813-1Monday, November 11, 20191.7
63813-2Tuesday, November 12, 20190
63813-3Tuesday, November 12, 20191.2
63813-4Tuesday, November 12, 20192.1
63935-1Sunday, November 17, 20191.9
63935-2Sunday, November 17, 20191.8
63935-3Sunday, November 17, 20191.4
63935-4Monday, November 18, 20190

 

Many thanks for the assistance. 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@DAXHeadroom , Try measures like

 

countx(filter(summarize(Table, Table[Date], "_1", sum(Table[Hours])),[_1]>0),[Date])

or

countx(filter(summarize(Table, Table[Date], "_1", sum(Table[Hours])),[_1]=0),[Date])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@DAXHeadroom , Try measures like

 

countx(filter(summarize(Table, Table[Date], "_1", sum(Table[Hours])),[_1]>0),[Date])

or

countx(filter(summarize(Table, Table[Date], "_1", sum(Table[Hours])),[_1]=0),[Date])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hello @amitchandak

 

Your solution above worked well - thank you! Now, I am having a similar problem when making additional DISTINCTCOUNTS of other columns. Specifically, I am employing the following two Measures to the below sample data table.

 

Flight Days Away = CALCULATE(DISTINCTCOUNT('Appended Metrics'[Dept Date Local]),'Appended Metrics'[Leg Hours]>0,'Appended Metrics'[Ver]="-V-",'Appended Metrics'[Local SAV Flights]=0)

Non-Flight Days Away = CALCULATE(COUNTAX(FILTER(SUMMARIZE('Appended Metrics', 'Appended Metrics'[Dept Date Local], "_1", SUM('Appended Metrics'[Leg Hours])),[_1]=0),[Dept Date Local]),'Appended Metrics'[Ver]="-V-", 'Appended Metrics'[Dept AP]<>"KSAV",'Appended Metrics'[Arrive AP]<>"KSAV")

 
Dept Date Local Dept AP Arrv AP Leg Hours Ver
9/21/2020 KSAV KMMU 1.6 -V-
9/21/2020 KMMU KMMU 0 -V-
9/22/2020 KMMU KMMU 0 -V-
9/22/2020 KMMU KHPN 0.3 -V-
9/23/2020 KHPN KHPN 0 -V-
9/23/2020 KHPN KSAV 1.8 -V-


My output is:

Flight Days Away = 3

Non-Flight Days Away = 2*

 

Since any given day should be counted once, and Flight Days take precedence,  

my desired output is:

Flight Days Away = 3

Non-Flight Days Away = 0

 

*I'm also confused as to why this is 2 versus 3. Seems odd to me. 

 

Any help woudl be very much appreciated. 

 

Regards,

 

@DAXHeadroom

AlB
Community Champion
Community Champion

Hi @DAXHeadroom 

Measure 1 = 
COUNTROWS( FILTER(DISTINCT(Table1[Date]), CALCULATE(SUM(Table1[Hours])) = 0))

 

Measure 2 = 
COUNTROWS( FILTER(DISTINCT(Table1[Date]), CALCULATE(SUM(Table1[Hours])) > 0))

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.