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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
patshannon11
Frequent Visitor

Create Measure that Counts and Ranks Another Measure and Updates when Filtered

My goal is to create a summary table containing a measure that scores each ZIP based on Facility 1 % Share, where the highest share has a score of 100%.  I would also like the scoring to maintain these rules when filtering on either ZIP or County.  I'm starting with a source data table similar to this:

 

ZIPCountyFacilityVolume
10001County AFacility 152
10002County AFacility 188
10003County AFacility 196
10004County AFacility 115
10005County AFacility 185
10006County BFacility 184
10007County BFacility 112
10008County BFacility 185
10009County BFacility 164
10010County BFacility 135
10001County AFacility 144
10002County AFacility 150
10003County AFacility 187
10004County AFacility 165
10005County AFacility 137
10006County BFacility 185
10007County BFacility 124
10008County BFacility 165
10009County BFacility 177
10010County BFacility 190
10001County AFacility 1102
10002County AFacility 1138
10003County AFacility 1146
10004County AFacility 165
10005County AFacility 1135
10006County BFacility 1134
10007County BFacility 162
10008County BFacility 1135
10009County BFacility 1114
10010County BFacility 185
10001County AFacility 194
10002County AFacility 1100
10003County AFacility 1137
10004County AFacility 1115
10005County AFacility 187
10006County BFacility 1135
10007County BFacility 174
10008County BFacility 1115
10009County BFacility 1127
10010County BFacility 1140
10001County AFacility 242
10002County AFacility 298
10003County AFacility 286
10004County AFacility 225
10005County AFacility 275
10006County BFacility 294
10007County BFacility 22
10008County BFacility 295
10009County BFacility 254
10010County BFacility 245
10001County AFacility 234
10002County AFacility 260
10003County AFacility 277
10004County AFacility 275
10005County AFacility 227
10006County BFacility 295
10007County BFacility 214
10008County BFacility 275
10009County BFacility 267
10010County BFacility 2100
10001County AFacility 292
10002County AFacility 2148
10003County AFacility 2136
10004County AFacility 275
10005County AFacility 2125
10006County BFacility 2144
10007County BFacility 252
10008County BFacility 2145
10009County BFacility 2104
10010County BFacility 295
10001County AFacility 284
10002County AFacility 2110
10003County AFacility 2127
10004County AFacility 2125
10005County AFacility 277
10006County BFacility 2145
10007County BFacility 264
10008County BFacility 2125
10009County BFacility 2117
10010County BFacility 2150

 

I first created a measure for Facility 1 % Share using the DAX below: 

 

Facility 1 % Share = 
DIVIDE(CALCULATE(SUM('Table'[Volume]), 'Table'[Facility] IN { "Facility 1" }),SUM('Table'[Volume]))

 

 

I then created a measure for Facility Share Rank using the DAX below:

 

Facility 1 Share RANK = 
RANKX(ALLSELECTED('Table'[ZIP]),[Facility 1 % Share],,ASC,Skip)

 

 

I then created a measure for ZIP Count using the DAX below:

 

ZIP Count = CALCULATE(MAXX('Table','Table'[Facility 1 Share RANK]),ALL('Table'))

 

 

Lastly, created a measure for Score using the DAX below:

 

Score = [Facility 1 Share RANK]/[ZIP Count]

 

 

The score works as intended without filters applied, but you can see in the 2nd and 3rd visual below when filtering by County or ZIP the score is not updating appropriately (in both cases scores should be 100%, 80%, 60%, 40%, and 20%).  It appears my ZIP Count is not interacting with the filters - would appreciate any advice there or open to other approaches as well.

 

patshannon11_1-1721915493648.png

 

patshannon11_2-1721915546140.png

 

patshannon11_3-1721915636891.png

1 ACCEPTED SOLUTION

@patshannon11 modify these two measures:

Facility 1 Share RANK =
RANKX(
    ALLSELECTED('Table'[County], 'Table'[ZIP]),
    [Facility 1 % Share],
    ,
    DESC,
    Skip
)
 
ZIP Count =
COUNTROWS(ALLSELECTED('Table'[ZIP], 'Table'[County]))
 
now it works also with County filter.
 
BeaBF_0-1722236824231.png

 

If it's ok, please accept the answer as solution.
 
BBF

View solution in original post

3 REPLIES 3
BeaBF
Super User
Super User

@patshannon11 Hi!

Try with these measures:

 

Facility 1 % Share =
DIVIDE(
    CALCULATE(SUM('Table'[Volume]), 'Table'[Facility] = "Facility 1"),
    CALCULATE(SUM('Table'[Volume]))
)
 
Facility 1 Share RANK =
RANKX(
    ALLSELECTED('Table'[ZIP]),
    [Facility 1 % Share],
    ,
    DESC,
    Skip
)
 
ZIP Count =
COUNTROWS(ALLSELECTED('Table'[ZIP]))
 
Score =
DIVIDE([Facility 1 Share RANK], [ZIP Count])
 
 
BeaBF_0-1721919222616.png

 

 
BBF

Appreciate the feedback.  It looks like this will give expected results when I filter on ZIP, but not when I filter on County?

@patshannon11 modify these two measures:

Facility 1 Share RANK =
RANKX(
    ALLSELECTED('Table'[County], 'Table'[ZIP]),
    [Facility 1 % Share],
    ,
    DESC,
    Skip
)
 
ZIP Count =
COUNTROWS(ALLSELECTED('Table'[ZIP], 'Table'[County]))
 
now it works also with County filter.
 
BeaBF_0-1722236824231.png

 

If it's ok, please accept the answer as solution.
 
BBF

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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