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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
hashari
Helper I
Helper I

Matrix Visual: Count of Total Values One Filter Level Up

I have a Matrix Visual, for the sake of this example:

a) Highest Level before expanding is Region (there are 2 Regions)

b) Next level is District (there are 5 districts in a Region)

c) Lowest Level is Store (there are 10 stores in a district)

 

What I am trying to get to is a measure/column that counts the next level up.

So for example, if I :

i. expand my matrix all the way down to store level, I want to see a count of 50  (10 stores in a District * 5 Districts)

ii. expand my matrix down to the district level, I want to see a count of 100 (10 stores in a District * 5 Districts * 2 Regions)

 

Not sure where to go from here.

1 ACCEPTED SOLUTION
v-kelly-msft
Community Support
Community Support

Hi  @hashari ,

 

Create a measure as below:

Measure = 
var _store=CALCULATE(DISTINCTCOUNT('Table'[store]),FILTER(ALL('Table'),'Table'[district ]=MAX('Table'[district ])&&'Table'[Region ]=MAX('Table'[Region ])))
var _district=CALCULATE(DISTINCTCOUNT('Table'[district ]),FILTER(ALL('Table'),'Table'[Region ]=MAX('Table'[Region ])))
var _region=CALCULATE(DISTINCTCOUNT('Table'[Region ]),ALL('Table'))
Return
IF(ISINSCOPE('Table'[store]),_store*_district,IF(ISINSCOPE('Table'[district ]),_store*_district*_region,COUNTROWS('Table')))

And you will see:

Annotation 2020-08-11 170147.png

I made a simple sample for reference,see attached.

 

Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!

View solution in original post

3 REPLIES 3
v-kelly-msft
Community Support
Community Support

Hi  @hashari ,

 

Create a measure as below:

Measure = 
var _store=CALCULATE(DISTINCTCOUNT('Table'[store]),FILTER(ALL('Table'),'Table'[district ]=MAX('Table'[district ])&&'Table'[Region ]=MAX('Table'[Region ])))
var _district=CALCULATE(DISTINCTCOUNT('Table'[district ]),FILTER(ALL('Table'),'Table'[Region ]=MAX('Table'[Region ])))
var _region=CALCULATE(DISTINCTCOUNT('Table'[Region ]),ALL('Table'))
Return
IF(ISINSCOPE('Table'[store]),_store*_district,IF(ISINSCOPE('Table'[district ]),_store*_district*_region,COUNTROWS('Table')))

And you will see:

Annotation 2020-08-11 170147.png

I made a simple sample for reference,see attached.

 

Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!

  -- I looked through a few of those examples, but not sure if I am connecting the dots properly.

I guess I need a little more help to reach my desired endpoint.

 

 

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.