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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Measures or table to determine the rank of column results within a row.

I have data arranged as follows:

 

Table 7

IndexBrand ABrand BBrand CBrand D
151-100101-150  
2151-20051-1000-50151-200
3 0-50 0-50
40-50101-150 101-150

 

Required 

 

IndexBrandValueRank
1Brand B101-1501
1Brand A51-1002
2Brand A151-2001
2Brand D151-2001
2Brand B51-1002
2Brand C0-503
3Brand B0-501
3Brand D0-501
4Brand B101-1501
4Brand D101-1501
4Brand A0-502

 

Would this be possible? 

 

I am a new user so step by step instructions would be appreciated.

 

Thanks

 

Jo

 

2 ACCEPTED SOLUTIONS

In Power Query, select all the columns apart from Index and choose Unpivot Columns from the Transform menu.

You then filter the Value column to remove blank rows (click on the down arrow in the Value header and uncheck 'blank')

You should Duplicate the column Value to preserve it in it's original form (right-click the header and choose Duplicate).

Then right-click the Value-Copy column and choose Split Column-> by delimiter (it should select '-' by default)

This will give you a numeric column which you can use in DAX to rank the data.

Close and Apply

 

In Power Bi, Add a calculated column to the table with DAX similar to the following

Rank within Index = VAR _index = 'Table'[Index]
RETURN
    RANKX(
        FILTER(
                'Table',
                'Table'[Index] = _index
                ),
        'Table'[Value - Copy.1],,,Dense 
        )

That's some reasonably complicated DAX for a beginner but basically it compares the values of column [Value - Copy.1] within each Index category and gives them a rank.

The column and table names may be different at your side so you'll have to sub them in.

View solution in original post

Anonymous
Not applicable

@HotChilli Fantastic! Thank you for answering this for me. Worked perfectly x.

View solution in original post

4 REPLIES 4
amitchandak
Super User
Super User

Anonymous
Not applicable

@amitchandak Thank you for this, I will apply the unpivot. What should I use to determine the rank?

In Power Query, select all the columns apart from Index and choose Unpivot Columns from the Transform menu.

You then filter the Value column to remove blank rows (click on the down arrow in the Value header and uncheck 'blank')

You should Duplicate the column Value to preserve it in it's original form (right-click the header and choose Duplicate).

Then right-click the Value-Copy column and choose Split Column-> by delimiter (it should select '-' by default)

This will give you a numeric column which you can use in DAX to rank the data.

Close and Apply

 

In Power Bi, Add a calculated column to the table with DAX similar to the following

Rank within Index = VAR _index = 'Table'[Index]
RETURN
    RANKX(
        FILTER(
                'Table',
                'Table'[Index] = _index
                ),
        'Table'[Value - Copy.1],,,Dense 
        )

That's some reasonably complicated DAX for a beginner but basically it compares the values of column [Value - Copy.1] within each Index category and gives them a rank.

The column and table names may be different at your side so you'll have to sub them in.

Anonymous
Not applicable

@HotChilli Fantastic! Thank you for answering this for me. Worked perfectly x.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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