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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

How to show dynamic value of top 5 show for each column?

Hey everyone,

 

Thanks a bunch for all your help so far.

I need to make a measure that shows the top 5 values for each column in this image.

JRP_175_0-1720685067274.png

 

The visual should change when I filter the data by any attribute.

Thanks a lot!

1 ACCEPTED SOLUTION
lkalawski
Super User
Super User

Hi @Anonymous,

 

I don't know your contex and the model you have, but based on the one table you showed, I've included two possible solutions below.
1. Dynamically changing ranking - this means that you will only see columns that are not empty, and additionally, in the future, you can create a slicer that allows the user to manipulate the number of columns (Rank) - for example, show only TOP 3 instead of TOP 5.

To do this, create a column in the table that will determine the ranking for each Branch.

Rank = 
VAR CurrentBranch = 'Raw Data'[Branch]
VAR CurrentAmount = 'Raw Data'[Amount]
RETURN
RANKX (
    FILTER ( 'Raw Data', 'Raw Data'[Branch] = CurrentBranch ),
    'Raw Data'[Amount],
    CurrentAmount,
    DESC,
    DENSE
)

 And then one measure that will dynamically show the values ​​based on the column.

Rank Value = 
CALCULATE (
    MAX ( 'Raw Data'[Amount] ),
    FILTER ( 'Raw Data', 'Raw Data'[Rank] = MAX('Raw Data'[Rank]) )
)

Result:

lkalawski_0-1720686994591.pnglkalawski_1-1720687006790.png

 

2. The second option is to create a dynamic ranking checker - instead of creating a column (which in fact increases the size of the dataset), you create a measure for each Rank - the downside here is that you need to know how much Rank you want to show and it is constant.
To do this, you create a measure for each rank:

Rank 1 Value = 
CALCULATE (
    MAX ( 'Raw Data'[Amount] ),
    FILTER (
        'Raw Data',
        RANKX (
            FILTER ( 'Raw Data', 'Raw Data'[Branch] = EARLIER('Raw Data'[Branch]) ),
            'Raw Data'[Amount],
            ,
            DESC,
            DENSE
        ) = 1
    )
)

Similarly for each other.

The Result:

lkalawski_2-1720687172803.pnglkalawski_3-1720687184293.png

 

If you have any further questions, feel free to ask.

 

If I helped, accept the post as a solution and give a kudos. 👍 Thanks! 😁

View solution in original post

2 REPLIES 2
lkalawski
Super User
Super User

Hi @Anonymous,

 

I don't know your contex and the model you have, but based on the one table you showed, I've included two possible solutions below.
1. Dynamically changing ranking - this means that you will only see columns that are not empty, and additionally, in the future, you can create a slicer that allows the user to manipulate the number of columns (Rank) - for example, show only TOP 3 instead of TOP 5.

To do this, create a column in the table that will determine the ranking for each Branch.

Rank = 
VAR CurrentBranch = 'Raw Data'[Branch]
VAR CurrentAmount = 'Raw Data'[Amount]
RETURN
RANKX (
    FILTER ( 'Raw Data', 'Raw Data'[Branch] = CurrentBranch ),
    'Raw Data'[Amount],
    CurrentAmount,
    DESC,
    DENSE
)

 And then one measure that will dynamically show the values ​​based on the column.

Rank Value = 
CALCULATE (
    MAX ( 'Raw Data'[Amount] ),
    FILTER ( 'Raw Data', 'Raw Data'[Rank] = MAX('Raw Data'[Rank]) )
)

Result:

lkalawski_0-1720686994591.pnglkalawski_1-1720687006790.png

 

2. The second option is to create a dynamic ranking checker - instead of creating a column (which in fact increases the size of the dataset), you create a measure for each Rank - the downside here is that you need to know how much Rank you want to show and it is constant.
To do this, you create a measure for each rank:

Rank 1 Value = 
CALCULATE (
    MAX ( 'Raw Data'[Amount] ),
    FILTER (
        'Raw Data',
        RANKX (
            FILTER ( 'Raw Data', 'Raw Data'[Branch] = EARLIER('Raw Data'[Branch]) ),
            'Raw Data'[Amount],
            ,
            DESC,
            DENSE
        ) = 1
    )
)

Similarly for each other.

The Result:

lkalawski_2-1720687172803.pnglkalawski_3-1720687184293.png

 

If you have any further questions, feel free to ask.

 

If I helped, accept the post as a solution and give a kudos. 👍 Thanks! 😁

Anonymous
Not applicable

That work very well, Thank a lot! 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.