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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
Anonymous
Not applicable

DAX measure to rank zeroes based on another column

Hi,
Could you please help me with a measure that can rank the zero values based on another column.
Sample dataset:

Student NameAttendence (%)Total MarkExpected Ranking
Ian70501
Becky75482
Cathy80383
John50384
Denny60205
Kin65106
Lena6377
Mark7238
Ean9009
Nora80010
Fahl700

11


The column "Expected Ranking" is the outcome of a measure that ranks the students based on the "Total Mark" column. But when it comes to the zero marks it should rank based on the "Attendance(%)" column.


To summarize, whenever there is a tie in marks, it should consider the Attendance column and rank accordingly.
(Row 3 and 4 are tie and it ranked based on Attendance column)

Any help on this appreciated.

Thank you.

 

1 ACCEPTED SOLUTION
wdx223_Daniel
Super User
Super User

Ranking =
VAR _mark = [Total Mark]
RETURN
    COUNTROWS (
        FILTER (
            ALLSELECTED ( Table[Student Name] ),
            [Total Mark] >= _mark
                && IF (
                    [Total Mark] = _mark,
                    'Table'[Student Name] <= MAX ( 'Table'[Student Name] ),
                    TRUE ()
                )
        )
    )

View solution in original post

4 REPLIES 4
wdx223_Daniel
Super User
Super User

Ranking =
VAR _mark = [Total Mark]
RETURN
    COUNTROWS (
        FILTER (
            ALLSELECTED ( Table[Student Name] ),
            [Total Mark] >= _mark
                && IF (
                    [Total Mark] = _mark,
                    'Table'[Student Name] <= MAX ( 'Table'[Student Name] ),
                    TRUE ()
                )
        )
    )

Anonymous
Not applicable

Thanks for the reply.
Is [Total Mark] a measure that is the sum of the Total Marks column?

it's a measure

=SUM(Table[Mark])

Anonymous
Not applicable

Thank you. That seems to work!

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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