cancel
Showing results for
Did you mean:

# Measure Ranking and Aggregations

Super User
1075 Views
Super User

## Measure Ranking and Aggregations

There have been a lot of posts over the years about how to use RANKX to create a measure, but not so many about how to use RANKX to create a measure that ranks a measure. In addition, nothing really definitive on how to aggregate measures. This post is intended to fix that.

Essentially, a measure is created via the following formula:

`Measure = SUM(Table1[Column2])/SUM(Table1[Column3])`

A simple approach to creating a ranking of this measure does not work very well (notice that there are 2 "Two" rows:

`Measure Rank (BAD) = RANKX(ALL(Table1),[Measure])`

Therefore, a slightly more complex approach is required:

```Measure Rank =
VAR __current = CALCULATE(MAX([Column1]))
VAR __table = SUMMARIZE(ALL(Table1),[Column1],"__Measure",[Measure])
RETURN MAXX(FILTER(__table1,[Column1]=__current),[__Rank])```

For good "measure", I have included aggregations of measures, which utilize a very similar technique:

```Measure StdDev =
VAR __table = SUMMARIZE(Table1,[Column1],"__Measure",[Measure])
RETURN STDEVX.P(__table,[__Measure]) ```

Proud to be a Datanaut!

Frequent Visitor

## Re: Measure Ranking and Aggregations

Very nice concept Greg. Definitely I would like to try it out. Thanks.

Frequent Visitor

## Re: Measure Ranking and Aggregations

Hi Greg, I tried this expression out and got the Dynamic Rank calculated. But I coudn't use it as a Dimension. means, I couldn't use it on axis as a Dimension of a Bar Chart. Is there any way that we use such expression to build a dynamic Dimension ?

Super User

## Re: Measure Ranking and Aggregations

@aardhala - In general, to use a measure in that way, you need to use the Disconnected Table Trick as this article demonstrates: https://community.powerbi.com/t5/Community-Blog/Solving-Attendance-with-the-Disconnected-Table-Trick...