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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
Anonymous
Not applicable

Count Distinct Not Working

Hello, 

 

I am having trouble counting the number of distinct weeks related to the following employee while ignoring the partition on "Reason Name" (shown in the column headers ex. "Work", "Partner", "Travel", etc.).   I've tried several methods to no avail. 

 
 

problem.png

 

I first tried this..
 
 CALCULATE(
         COUNTROWS(DISTINCT('Avg Weekly CRM Hours by Tech/Week/Reason'[Week Start Date]))
        , ALLSELECTED('Avg Weekly CRM Hours by Tech/Week/Reason'[Reason Name])
)
 Then tried this... 
 
CALCULATE(
    COUNTROWS(
        DISTINCT(
        SELECTCOLUMNS('Avg Weekly CRM Hours by Tech/Week/Reason'
         , "Week Start Date"
        , 'Avg Weekly CRM Hours by Tech/Week/Reason'[Week Start Date]
        )))
         , ALLEXCEPT('Avg Weekly CRM Hours by Tech/Week/Reason','Avg Weekly CRM Hours by Tech/Week/Reason'[Reason Name]
         ))
 
Neither option worked
1 REPLY 1
Ashish_Mathur
Super User
Super User

Hi,

You should first create a Calendar Table and then build a relationship (Many to One and Single) from the Week start date column to the Date column of the Calendar Table.  To your visual, drag Month name and Date from the Calendar Table.  Write these measures

Total = distinctcount('Avg Weekly CRM Hours by Tech/Week/Reason'[Week start date])

Measure = calculate([Total],all(calendar[Date]))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.