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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
depple
Helper III
Helper III

DISTINCTCOUNT in measure - Sum of subtotals issue

Hi,

 

Background: I wish to create a matrix that uses a measure that distinctcounts the number of base products in each store. Each store has a responsible salesman.

 

Here are two mockup tables of my data:

 

Inventory table   
Store IDSKU IDSKUBase Product
11Product A - Small BoxProduct A
12Product A - Big boxProduct A
13Product B - Small BoxProduct B
14Product B - Big boxProduct B
15Product C - Small BoxProduct C
16Product D - Big boxProduct D
17Product D - Small BoxProduct D
21Product A - Small BoxProduct A
22Product A - Big boxProduct A
23Product B - Small BoxProduct B
24Product B - Big boxProduct B
25Product C - Small BoxProduct C

 

Store Data  
Store IDStore NameResponsible
1Store AJohn
2Store BJohn

 

I have created a 'matrix' below where the correct hierarchy totals for this measure should be like according to the mockup tables:

 

depple_0-1615391188348.png

 

Problem: I get it correct at Store Name level by using DISTINCTCOUNT, but I have ground to a halt with the total at Responsible level.

 

In order to adjust the counting method with the hierarchy level, I believe that ISINSCOPE could be of help:

 

My current measure:

Number of base products =

IF( ISINSCOPE('Store Data'[Store Name]),
DISTINCTCOUNT('Inventory Table'[Base Product]),

IF( ISINSCOPE('Store Data'[Responsible]),
[What to put here???]
)

 

I would really appreciate any help on this.

 

Regards,

depple

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@depple , Try a measure like

 

Sumx(Values('Store Data'[Store Name]),calculate(DISTINCTCOUNT('Inventory Table'[Base Product])))

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@depple , Try a measure like

 

Sumx(Values('Store Data'[Store Name]),calculate(DISTINCTCOUNT('Inventory Table'[Base Product])))

@amitchandak 

 

Wow, as far as I can observe, it works perfect!

 

Thank you!

 

Regards,

depple

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors