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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Pelahibdo
Frequent Visitor

Incorrect result using Rankx for subcategories when adding new columns

Hi,

I am trying to rank by subcategory (product ID) in a table and it works fine using the following metric.

Rank = rankx(ALLSELECTED('Product'[Product ID]),calculate(sum('Sales'[Sale])))

But as soon as I add new columns such as Product Name, the ranking becomes 1 for all the rows. I need to add the extra columns (4-5 new columns that could be from different tables) to show more information in my visual but don't want them to affect the ranking. 

Here is my table:

Sales personProduct IDSalesRank
A11A5002
A21B10001
A31C15003
B41D20002
B51E25001
C61F30004
C71G35003
C81F40002
C945001

 

The sale value comes from Sales table which has a relationship with my product table using Product ID (there could be few rows per product ID, so I need to use sum([Sale]))

 

Thanks

4 REPLIES 4
Anonymous
Not applicable

Hi  @Pelahibdo ,

 

Please try this formula:

Rank = VAR SalesPersonGroup = 
    FILTER(
        ALL('Table'),
        'Table'[Sales Person] = SELECTEDVALUE('Table'[Sales Person])
    )
RETURN
    RANKX(
        SalesPersonGroup,
        CALCULATE(SUM('Table'[Sales])),
        ,
        DESC,
        DENSE
    )

 

vbofengmsft_0-1729839893217.png

 

I've made a test for your reference:

1\Mya data table(Table)

vbofengmsft_1-1729839936788.png

2\Add a measure

Rank = VAR SalesPersonGroup = 
    FILTER(
        ALL('Table'),
        'Table'[Sales Person] = SELECTEDVALUE('Table'[Sales Person])
    )
RETURN
    RANKX(
        SalesPersonGroup,
        CALCULATE(SUM('Table'[Sales])),
        ,
        DESC,
        DENSE
    )

3\Result

vbofengmsft_2-1729839970184.png

 

Best Regards,

Bof

 

 

Thanks, but gives me the following error:

Visual have exceed the available resources.

Anonymous
Not applicable

Hi @Pelahibdo ,

 

Please review the attached .pbix file to confirm that it meets your requirements.

Alternatively, you may consider providing your .pbix file (please ensure any private data is removed).

 

Best Regards,

Bof

lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information. Do not include anything that is unrelated to the issue or question.

Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors