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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Cevola
Helper I
Helper I

Ranking Data in Power BI DAX

Hi,

I am trying to Rank data in Power BI. Pictures is a meature. Now i want to create a measure to rank Pictures. The location with the highest pictures should be 1 and so on.

Cevola_0-1678726929232.png

This is the measure i created but it gives me only 2 values 1 and 889419. 1 for all having some value and 0 for nulls.
Measure = rankx(ALLSELECTED('Table'),'Table'[Pictures],,DESC,Skip)

Please help me.

 

 

 

2 ACCEPTED SOLUTIONS

Actually, it could be that you're referencing the table without the column in the ALLSELECTED.

Try this...

_Measure =
RANKX (
    ALLSELECTED ( 'Table'[Location] ),
    'Table'[Pictures],
    ,
    DESC,
    SKIP
)
Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
chrome-9xf-Zagzel-B

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
KIfp67uy-Sr
Proud to be a Super User!PBI-Super-User-Rank-30x30-1x

View solution in original post

If I understand correctly, this measure should work.

(change [Measure] to whatever you've called it)

 

RankPictures = 
    SWITCH(
        TRUE(),
        [Measure] < 21, 1,
        [Measure] < 51, 0.7,
        [Measure] < 101, 0.5,
        [Measure] < 201, 0.3,
        0
    )

 

Please mark all the responses that solved your issues as the solution.

 

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
chrome-9xf-Zagzel-B

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
KIfp67uy-Sr
Proud to be a Super User!PBI-Super-User-Rank-30x30-1x

View solution in original post

6 REPLIES 6
Cevola
Helper I
Helper I

Thank You!

KNP
Super User
Super User

Hi @Cevola,

 

Just a couple of things first.

You've posted a DAX question in the Power Query forum. You'll probably get an answer quicker if posted in the DAX forum.

Please paste data next time, not a screen shot. It makes it faster to come up with a solution.

 

As for the solution, I've thrown together a very simple example, attached.

The code should be working fine which leads me to believe the issue is with your model.

Can you post a screen shot of your model and the relationships?

 

Thanks

 

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
chrome-9xf-Zagzel-B

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
KIfp67uy-Sr
Proud to be a Super User!PBI-Super-User-Rank-30x30-1x

Actually, it could be that you're referencing the table without the column in the ALLSELECTED.

Try this...

_Measure =
RANKX (
    ALLSELECTED ( 'Table'[Location] ),
    'Table'[Pictures],
    ,
    DESC,
    SKIP
)
Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
chrome-9xf-Zagzel-B

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
KIfp67uy-Sr
Proud to be a Super User!PBI-Super-User-Rank-30x30-1x

Thank You, your measure worked like magic.

Now, I need to create one more measure to Rank the pictures 

Rank of: 

Pictures  –  

top 20 = 1 

Top 50 = 0.7 

Top 100 = 0.5 

Top 200 = 0.3 

Can you please help me in this?

 

Thanks a lot in advance

Top 200 = 0.3 

If I understand correctly, this measure should work.

(change [Measure] to whatever you've called it)

 

RankPictures = 
    SWITCH(
        TRUE(),
        [Measure] < 21, 1,
        [Measure] < 51, 0.7,
        [Measure] < 101, 0.5,
        [Measure] < 201, 0.3,
        0
    )

 

Please mark all the responses that solved your issues as the solution.

 

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
chrome-9xf-Zagzel-B

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
KIfp67uy-Sr
Proud to be a Super User!PBI-Super-User-Rank-30x30-1x

If I understand correctly, this measure should work.

(change [Measure] to whatever you've called it)

 

RankPictures = 
    SWITCH(
        TRUE(),
        [Measure] < 21, 1,
        [Measure] < 51, 0.7,
        [Measure] < 101, 0.5,
        [Measure] < 201, 0.3,
        0
    )

 

Please mark all the responses that solved your issues as the solution.

 

Have I solved your problem?
Please click Accept as Solution so I don't keep coming back to this post, oh yeah, others may find it useful also ;).
chrome-9xf-Zagzel-B

If you found this post helpful, please give Kudos.
It gives me a sense of instant gratification and, if you give me Kudos enough times, magical unicorns will appear on your screen.
If you find my signature vaguely amusing, please give Kudos.
KIfp67uy-Sr
Proud to be a Super User!PBI-Super-User-Rank-30x30-1x

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors