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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

Reply
kfinn
Frequent Visitor

RANKX- Rank By User

Hi Everyone-

I am new to DAX and I have read a handful of blogs on RANKX, but I still can't figure out what I am doing wrong on the below scenario:

I want to create a column that ranks user's opportunities by the revenue (Owner Opportunity Rank).  Here are the desired results:

_ownerid_valueExpected Annual RevenueOpportunity NameOwner Opportunity Rank
aaaa-1 $                                              100.00Opp12
aaaa-1 $                                              200.00Opp21
aaaa-2 $                                              400.00Opp32
aaaa-2 $                                              500.00Opp41

 

Here is my code:

 

I created a measurement:

TotalRevenue = SUM(opportunities[Expected Annual Revenue])

 

I created the desired column

Owner Opportunity Rank = RANKX (ALL(opportunities[_ownerid_value]), [TotalRevenue])

 

The issue is my "Owner Opportunity Rank" column returns all 1's.

 

Any help is appreciated!

1 ACCEPTED SOLUTION
Sean
Community Champion
Community Champion

@kfinn

How about this?

Owner Opportunity Rank =
RANKX (
    ALL ( opportunities[Opportunity Name] ),
    CALCULATE (
        SUM ( opportunities[Expected Annual Revenue] ),
        ALLEXCEPT (
            opportunities,
            opportunities[_ownerid_value],
            opportunities[Opportunity Name]
        )
    )
)

Owner Ranks2.png

 

EDIT: You want to Rank the Opportunity Names for each Owner!

I think that's what you meant? Smiley Happy

View solution in original post

5 REPLIES 5
Sean
Community Champion
Community Champion

@kfinn

Your RANK formula works as a MEASURE not a COLUMN

 

If you want a column in the Data View - this should work

Owner Opportunity Rank =
RANKX (
    ALL ( opportunities[_ownerid_value] ),
    CALCULATE (
        SUM ( opportunities[Expected Annual Revenue] ),
        ALLEXCEPT ( opportunities, opportunities[_ownerid_value] )
    )
)

Good Luck! Smiley Happy

 

Owner Ranks.png

kfinn
Frequent Visitor

Thanks Sean for the quick reply.

 

I think this is on the right track, but I believe this is ranking the owner himself.  I am looking for the opportunity rank by the user.  The rank should be determined by expected revenue.  So I am looking for the "Owner Opportunity Rank" column here..

 

_ownerid_valueExpected Annual RevenueOpportunity NameOwner Opportunity Rank
aaaa-1 $                                              100.00Opp12
aaaa-1 $                                              200.00Opp21
aaaa-2 $                                              400.00Opp32
aaaa-2 $                                              500.00Opp41

 

Owner = aaaa-1 has two opportunites.  Opp2 has a greater revenue than Opp1 so the Onwer Opportunity Rank = 1 for Opp2 and so forth...  I apologize if that is not clear in my first post.

 

I when I read the RANKX documentation, I feel like this should be the column:

Owner Opportunity Rank = RANKX (
ALL ( opportunities[_ownerid_value] ),
opportunities[Expected Annual Revenue]
)

 

But I still get all 1's...

Sean
Community Champion
Community Champion

@kfinn

How about this?

Owner Opportunity Rank =
RANKX (
    ALL ( opportunities[Opportunity Name] ),
    CALCULATE (
        SUM ( opportunities[Expected Annual Revenue] ),
        ALLEXCEPT (
            opportunities,
            opportunities[_ownerid_value],
            opportunities[Opportunity Name]
        )
    )
)

Owner Ranks2.png

 

EDIT: You want to Rank the Opportunity Names for each Owner!

I think that's what you meant? Smiley Happy

kfinn
Frequent Visitor

Yes- This is what I am looking for.  I am not following how DAX is grouping by the _ownerid_value but now that I have the acceptable solution, I can play around with it.  Much thanks to you!!

Phil_Seamark
Microsoft Employee
Microsoft Employee

You could try this approach.  It might work so let me know how you get on

 

This Col Might work = CALCULATE( COUNTROWS('Opportunities'),
                FILTER(
                        ALL('Opportunities'),
                        'Opportunities'[_ownerid_value]=EARLIER('Opportunities'[_ownerid_value])
                        && 'Opportunities'[Expected Annual Revenue] < EARLIER('Opportunities'[Expected Annual Revenue])
                         ))+1

To learn more about DAX visit : aka.ms/practicalDAX

Proud to be a Datanaut!

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.