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
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
Anonymous
Not applicable

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
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

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 community update carousel

Fabric Community Update - June 2025

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