Forum Discussion

patshannon11's avatar
patshannon11
Frequent Visitor
2 years ago
Solved

Create Calculated Table with a Rank Column that Interacts with Columns in Original Source Table

My goal is to create a summary table with a rank column that will update when filtering on different columns from the source data table.  I'm starting with a source data table similar to this:

 

ZIP CodeSettingServiceVolume
10001InpatientCancer15
10002InpatientCancer8
10003InpatientCancer2
10004InpatientCancer5
10001OutpatientCancer6
10002OutpatientCancer13
10003OutpatientCancer2
10004OutpatientCancer7
10001InpatientCancer5
10002InpatientCancer9
10003InpatientCardiac18
10004InpatientCardiac4
10001OutpatientCardiac5
10002OutpatientCardiac2
10003OutpatientCardiac1
10004OutpatientCardiac5
10001InpatientCardiac8
10002InpatientCardiac4
10003InpatientCardiac6
10004InpatientCardiac13
10001OutpatientNeurologic14
10002OutpatientNeurologic5
10003OutpatientNeurologic8
10004OutpatientNeurologic5
10001InpatientNeurologic6
10002InpatientNeurologic11
10003InpatientNeurologic3
10004InpatientNeurologic9
10001OutpatientNeurologic1
10002OutpatientNeurologic5
10003OutpatientOrthopedic6
10004OutpatientOrthopedic5
10001InpatientOrthopedic4
10002InpatientOrthopedic1
10003InpatientOrthopedic12
10004InpatientOrthopedic3
10001OutpatientOrthopedic2
10002OutpatientOrthopedic1
10003OutpatientOrthopedic5
10004OutpatientOrthopedic18

 

I've created a calculated table with a rank measure using the DAX below:

 

 

 

 

Ranking Table = SUMMARIZE('Data','Data'[Service],"Volume",SUM(Data[Volume]))
Rank = RANK(DENSE, ALLSELECTED('Ranking Table'), ORDERBY('Ranking Table'[Volume], DESC), LAST)​

 

 

 

 

This results in the following summary table:

 

RankService

Volume

1Cancer72
2Neurologic67
3Cardiac66
4Orthopedic57

 

I would utlimately like the Rank column to update when filtering on columns "ZIP Code" and "Setting" in the original source table, but I'm having trouble finding out how to create that relationship.  For example, If I filter on "ZIP Code = 10001" and "Setting = Outpatient" I would like the summary table to read as follows:

 

RankService

Volume

1Neurologic15
2Cancer6
3Cardiac5
4Orthopedic

2

 

Any help is appreciated!

4 Replies