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

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

Reply
PowerKoen
Frequent Visitor

MATRIX distinct

Hello,

I have the following colomn in a table:
-Date

-Name
-CustomerCode
-Weeknumber

I made a MATRIX, with rows CustomerCode, and value (distinctcount of customercode)

                                      Week 1 Week 2 Week 3     Total
CustomerCode              1             1         1                 1
CustomerCode              1                        1                 1
CustomerCode                              1         1                 1
CustomerCode               1                        1                 1 
Total                              3              2        4                  4 

 

The total below is correct, but the colomnsubtotal is not showing correctly (must add the values horizontality)


How can I achieve this?

2 ACCEPTED SOLUTIONS
Michiel
Resolver III
Resolver III

Technically the subtotals are correct in that they just do the distinctcount on all the weeks together - so for one customer code, it will never be more than one. If you want to count the number of weeks each customer appears, you'll have to calculate by week and add these:
SUMX(VALUES([Weeknumber]),

   CALCULATE(DISTINCTCOUNT([CustomerCode]))

)

(Add appropriate table names etc.)

View solution in original post

Thanks, that did the trick but with this code it was a bit better and accurate

 

COUNTROWS(SUMMARIZE(customers,customers[Date],customers[customercode]))

View solution in original post

3 REPLIES 3
Michiel
Resolver III
Resolver III

Technically the subtotals are correct in that they just do the distinctcount on all the weeks together - so for one customer code, it will never be more than one. If you want to count the number of weeks each customer appears, you'll have to calculate by week and add these:
SUMX(VALUES([Weeknumber]),

   CALCULATE(DISTINCTCOUNT([CustomerCode]))

)

(Add appropriate table names etc.)

Thanks, that did the trick but with this code it was a bit better and accurate

 

COUNTROWS(SUMMARIZE(customers,customers[Date],customers[customercode]))
AnthonyTilley
Solution Sage
Solution Sage

dont distinct count the customer code as this will always give a one in your row total as you are using the customer code as the row header 

 

So distinctcount(CustomerCode) would always give 1 in your row total 

like wise distinctcount(weeknumber) would give you a 1 in your colunm total

 

instead use distinctcount(name) the Name filed is not used in your table headers or rows should will produce the correct result and this should solve your problem 

 

Untitled.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
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.