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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
ADP007
Helper IV
Helper IV

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

 

 

 

2020-10-09_16-00-21.png

1 ACCEPTED SOLUTION

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)

 

mul1.jpg

 

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)

 

mul2.jpg

 

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.

View solution in original post

10 REPLIES 10
v-zhenbw-msft
Community Support
Community Support

Hi @ADP007 ,

 

Glad to hear that you have solved the issue.

Please kindly mark your reply as a solution to help others find it more quickly. Thanks!

 

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.

amitchandak
Super User
Super User

@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.

@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.

 

CATEGORYSECTORBRANDMEDIAConvincingRankDraws attentionRankInspiringRankLikeabilityRank

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
)

 

 

mul1.jpg

 

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.

hi @v-zhenbw-msft 

 

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? 

2020-10-19_14-20-48.png

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)

 

mul1.jpg

 

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)

 

mul2.jpg

 

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.

hi @v-zhenbw-msft 

 

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

 

 

2020-10-20_12-59-56.png

hi @v-zhenbw-msft 

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.

 

2020-10-21_08-48-18.png

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

Thanks

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

 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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