cancel
Showing results for
Search instead for
Did you mean:
Highlighted
Helper III

## multiple rank columns in matrix table

Hi all, I would need to have an extra rank column for each criteria that is selected in the criteria filter.

Is that possible

Many thanks

David

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support

Hi @ADP007 ,

We can create a calculate column and a measure to meet your requirement.

1. Create a rank column.

``````AVG. RANK =
RANKX(
FILTER(
mScoreData,
[CATEGORY]=EARLIER([CATEGORY])
&&[CRITERIA]=EARLIER([CRITERIA])
),
mScoreData[SCORE],,DESC,Dense)
``````

2. Then create an average measure.

``````AVGRank =
var _total =
CALCULATE(
SUM(mScoreData[AVG. RANK]),
FILTER(
ALLSELECTED(mScoreData),
[CATEGORY]=MAX([CATEGORY])
&&[CATEGORY2]=MAX([CATEGORY2])
&&[MEDIA]=MAX([MEDIA])
&&[LABEL]=MAX([LABEL])))
var _count = CALCULATE(DISTINCTCOUNT(mScoreData[CRITERIA]),ALLSELECTED(mScoreData))
return
DIVIDE(_total,_count)``````

If you have any question, please kindly ask here and we will try to resolve it.

Best regards,

Community Support Team _ zhenbw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

BTW, pbix as attached.

10 REPLIES 10
Highlighted
Super User IV

@ADP007 , Not very clear. You can not add a column when the filter is applied, You can change Rank calculation based on.

Please provide your feedback comments and advice for new videos
Tutorial Series Dax Vs SQL Direct Query PBI Tips
Appreciate your Kudos.

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

Highlighted
Helper III

@amitchandak, thanks for your time. When I select items from the criteria filter the dimension gets added to the matrix.

In my image I have 4 criterias selected and thus 4 columns in my matrix table. I would like to have an extra column in the matrix for each dimension with the ranking. Something like this but of course dynamically. Hope this helps.

 CATEGORY SECTOR BRAND MEDIA Convincing Rank Draws attention Rank Inspiring Rank Likeability Rank
Highlighted
Community Support

Hi @ADP007 ,

We can create a measure and put it in Values to meet your requirement.

``````Rank =
RANKX (
FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Media] = MAX ( 'Table'[Media] ) ),
CALCULATE ( SUM ( 'Table'[value] ) ),
,
ASC,
DENSE
)
``````

If it doesn’t meet your requirement, could you please provide a mockup sample based on fake data?

It will be helpful if you can show us the exact expected result based on the tables.

Please upload your files to OneDrive For Business and share the link here. Please don't contain any Confidential Information or Real data in your reply.

Best regards,

Community Support Team _ zhenbw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

BTW, pbix as attached.

Highlighted
Helper III

Hi, On holiday this week but will try and give an answer as soon as possible.

Thanks

Highlighted
Helper III

Hi, Here is the link, hope it works : mScore

There is an xls file with what I'm trying to obtain.

Thanks for any help

David

Highlighted
Helper III

I have managed to place a rank column following your mockup. However I'm still stuck as I need to calculate a new column based on the various rank columns. In the image below I would need an order by which is the average rank for on line. For example line 1 would have an order by of 5.4 (6+6+4+6+5)/5. Is this possible?

Highlighted
Community Support

Hi @ADP007 ,

We can create a calculate column and a measure to meet your requirement.

1. Create a rank column.

``````AVG. RANK =
RANKX(
FILTER(
mScoreData,
[CATEGORY]=EARLIER([CATEGORY])
&&[CRITERIA]=EARLIER([CRITERIA])
),
mScoreData[SCORE],,DESC,Dense)
``````

2. Then create an average measure.

``````AVGRank =
var _total =
CALCULATE(
SUM(mScoreData[AVG. RANK]),
FILTER(
ALLSELECTED(mScoreData),
[CATEGORY]=MAX([CATEGORY])
&&[CATEGORY2]=MAX([CATEGORY2])
&&[MEDIA]=MAX([MEDIA])
&&[LABEL]=MAX([LABEL])))
var _count = CALCULATE(DISTINCTCOUNT(mScoreData[CRITERIA]),ALLSELECTED(mScoreData))
return
DIVIDE(_total,_count)``````

If you have any question, please kindly ask here and we will try to resolve it.

Best regards,

Community Support Team _ zhenbw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

BTW, pbix as attached.

Highlighted
Helper III

So many thanks for your help, I don't use Power Bi enough or often enough.

I have three remarks:

1. The Rank columns seems not to be correct (there are several rows with the value 1)
2. Is it possible to have the average as a dimension so that it is possible to apply a sort on it?
3. The average rank doesn't seem to be correct when you filter on media/brand/sector

Thanks

Highlighted
Helper III

I understand why the rank was not correct. The matrix needs to be fully expanded for the rank to work.

So the only thing I need is to have this avr rang as a column. The reason is for the user to sort asc or desc on this value.

Thanks

D.

## Helpful resources

Announcements

#### Power Platform Community Conference

Check out the on demand sessions that are available now!

#### Microsoft Power Platform Communities

Check out the Winners!

#### Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors