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

Prepping for a Fabric certification exam? Join us for a live prep session with exam experts to learn how to pass the exam. Register 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
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
May PBI 25 Carousel

Power BI Monthly Update - May 2025

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

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

May 2025 Monthly Update

Fabric Community Update - May 2025

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

Top Solution Authors