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
greenskmachine2
Frequent Visitor

RANKX ASC incorrectly starting at 2

Hi there,

I am, for the first time, using RANKX for reporting different data both in a descending and an ascending way. 
I've had no issues with DESC, but for some reason ASC always starts at 2. It seems that everything else that's in my DimBusiness table, that I'm not interested in/is filtered out, becomes a 1. I don't know how to manage it. Obviously my filters are wrong. 

I'm using this: 

Ranking Ave =
RANKX( ALL(DimBusiness[BusinessName]), CALCULATE( [Weighted Ave],
KEEPFILTERS( DATESBETWEEN( Dim[CalendarDate], [ReportingStartDate], [ReportingEndDate] ) ) ),
, ASC, DENSE )

 

Others have had the same issues, but I can't wrap my head around it. Help much appreciated. 

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but please try something like below.

 

Ranking Ave =
VAR _t =
    FILTER ( ALL ( DimBusiness[BusinessName] ), ( NOT [Weighted Ave] = 0 ) )
RETURN
    RANKX (
        _t,
        CALCULATE (
            [Weighted Ave],
            KEEPFILTERS (
                DATESBETWEEN ( Dim[CalendarDate], [ReportingStartDate], [ReportingEndDate] )
            )
        ),
        ,
        ASC,
        DENSE
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

4 REPLIES 4
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but please try something like below.

 

Ranking Ave =
VAR _t =
    FILTER ( ALL ( DimBusiness[BusinessName] ), ( NOT [Weighted Ave] = 0 ) )
RETURN
    RANKX (
        _t,
        CALCULATE (
            [Weighted Ave],
            KEEPFILTERS (
                DATESBETWEEN ( Dim[CalendarDate], [ReportingStartDate], [ReportingEndDate] )
            )
        ),
        ,
        ASC,
        DENSE
    )

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

This seems to have worked. Thanks very much. 

Are you able to explain what the issue was? 

Hi, 

I tried to create a virtual table, inside the measure, that does not contain zero value of [Weighted Ave]. And then, I tried to rank among the virtual table.

 

If you want to change the condition, you can try altering the below part.

 

VAR _t =
FILTER ( ALL ( DimBusiness[BusinessName] ), ( NOT [Weighted Ave] = 0 ) )

 

I hope this explains.

Thank you. 

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
powerbiexpert22
Impactful Individual
Impactful Individual

Hi @greenskmachine2 ,

the reason could be the presence of blank values in your measure [Weighted Ave]. please share sample data if possible

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.