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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
DTGPete
Frequent Visitor

Need Help Summing a Distinct Count in a Matrix Across all Rows

Hello,

I'm trying to sum a distinct count of days within a Matrix in Power BI. There are 3 distinct dates (8/1 through 8/3) with a value of 1 for 'Unique Days' across all rows - see image below.

 

DTGPete_0-1686871854740.png

 

When I drill up to the 'Customer Name' I expect the value to sum to 3, as there are 3 distinct dates associated across all rows - see Image below.

 

DTGPete_1-1686871935177.png

 

 

Formula's currently being used:

 

Unique Days =
If( DS_main_for_usa[BILLABLE_HOURS] > 0 || DS_main_for_usa[NON_BILLABLE_HOURS] > 0,
IF (CONTAINSSTRING(DS_main_for_USA[TASK_NAME], "- Canada -"),
CALCULATE((DISTINCTCOUNT(DS_main_for_usa[CALENDAR_DATE])) )))

 

Unique Days V2
SUMX(ADDCOLUMNS(SUMMARIZE(DS_main_for_usa, DS_main_for_usa[ENGAGEMENT_DIVISION_NAME],
DS_main_for_usa[CUSTOMER_NAME],DS_main_for_usa[ENGAGEMENT_NAME],DS_main_for_usa[TASK_NAME],
DS_main_for_usa[ENGAGEMENT_STATUS]),"MAXDays", MAXX(DS_main_for_usa, DS_main_for_usa[Unique Days])),[MAXDays])

 

Can anyone help? My formula for Unique Days V2 is returning 4 and not 3 for some reason. 

Thank you!!

1 ACCEPTED SOLUTION

Okay I was making this way more complicated than needed.  

 

The following measure solved my issue: 

Unique Days = CALCULATE(DISTINCTCOUNT(DS_main_for_usa[CALENDAR_DATE]),DS_main_for_usa[UNIQUEDAYS]<>BLANK())

View solution in original post

3 REPLIES 3
Mahesh0016
Super User
Super User

@DTGPete  I hope this helps you!! Thank You!!
Unique Days V2 =
SUMX (
ADDCOLUMNS (
SUMMARIZE (
DS_main_for_usa,
DS_main_for_usa[ENGAGEMENT_DIVISION_NAME],
DS_main_for_usa[CUSTOMER_NAME],
DS_main_for_usa[ENGAGEMENT_NAME],
DS_main_for_usa[TASK_NAME],
DS_main_for_usa[ENGAGEMENT_STATUS]
),
"MAXDays", MAXX ( VALUES ( DS_main_for_usa ), DS_main_for_usa[Unique Days] )
),
[MAXDays]
)

##############################ELSE###############################

Unique Days V2 =
SUMX (
ADDCOLUMNS (
SUMMARIZE (
DS_main_for_usa,
DS_main_for_usa[ENGAGEMENT_DIVISION_NAME],
DS_main_for_usa[CUSTOMER_NAME],
DS_main_for_usa[ENGAGEMENT_NAME],
DS_main_for_usa[TASK_NAME],
DS_main_for_usa[ENGAGEMENT_STATUS]
),
"MAXDays", MAXX ( VALUES ( DS_main_for_usa[Unique Days] ), DS_main_for_usa[Unique Days] )
),
[MAXDays]
)

@Mahesh0016  - thank you so much for answering my question.  Unfortunately, that meaure still returns a value of 4 instead of 3.  Any ideas? 

Okay I was making this way more complicated than needed.  

 

The following measure solved my issue: 

Unique Days = CALCULATE(DISTINCTCOUNT(DS_main_for_usa[CALENDAR_DATE]),DS_main_for_usa[UNIQUEDAYS]<>BLANK())

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.