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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
morrtenjansen
Frequent Visitor

Measure to rank within subcategories (for filtering table visual to TopX within subcategory)

Context: TransactionTable "RepdataH". It has dimTables on it, but that will be in a next step, current issue only concerns RepdataH.

I need to rank the records via a measure, as it is, within a category ("Restaurant"), and I have a number to rank by ("Random number ..."), per record. That is to show a table with a random subset (say, 3) of records per restaurant.

 

But when used in a table (only using fields from RepdataH) all records get rank 1.

 

(Most of the tips I have found regarding "Rank by Category" or "Get topX by Category" use calculated columns, but I need it interactively,)

 

Pls. advice (all the VARing is mostly for testing purposes).

 

MsrDraw =
VAR er = MAX(RepdataH[Restaurant])
VAR tbl =
SELECTCOLUMNS(
    Filter(
            ALL(RepdataH)
        ,
            RepdataH[Restaurant]=er
    )
,
        [Random Number …]
)
VAR en = MAX(RepdataH[Random Number …])
VAR rx =
rankx(
    tbl
,
    en
)
RETURN
rx

 

Thanks for advise.

1 REPLY 1
v-rzhou-msft
Community Support
Community Support

Hi @morrtenjansen ,

 

I think your calculation is based on your data model.

Please share a sample file with us and show us with a screenshot. This will make it easier for us to find the solution.

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

Check out the October 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

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

Top Kudoed Authors