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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
mrpowrbihelp
Frequent Visitor

RankX with Filters

Hi,

 

I have a RankX formula that almost works.

I have a visual with a table that has each model we have but it needs to filter based on the account picked or the status of model ect.

This visual has multiple description fields for example, the intro date of the model the msrp ect and then measures with sales.

 

The current Rankx formula i'm using is:
Calculate(Rankx(All("Model column"),"Sales Measure"),AllSelected("Description fields"),AllSelected("Description fields"),AllSelected("Description fields"),AllSelected("Description fields"),AllSelected("Description fields"),AllSelected("Description fields"),AllSelected("Description fields"),AllSelected("Description fields"))

 

It almost gives me the result i am looking for. The table "model" is coming from is the Master product table and it has about 10,000 distinct models. So this rank formula says my lowest rank is 10,000, but i want it to be say 250 (the amount of models showing in the visual after the filters are applied)

How can i adjust the formula or it is possibly my relationships and i shouldn't be using the model column from the master product table?

 

Thank you!

3 REPLIES 3
OwenAuger
Super User
Super User

Hi @mrpowrbihelp 

 

It would be best to see the tables/relationships, along with which columns you are using in the visual.

Could you possibly post a pbix with santised data?

 

But based on your description so far, here is a possible measure structure, which I could be more confident in with some more details on the model.

 

=
VAR ModelsForRanking =
    CALCULATETABLE (
        SUMMARIZE ( SalesTable, ModelTable[Model Column] ),
        ALLSELECTED ()
    )
RETURN
    RANKX (
        ModelsForRanking,
        CALCULATE ( "Sales Measure", ALLEXCEPT ( ModelTable, ModelTable[Model Column] ) )
    )

 

Kind regards,

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn
v-lili6-msft
Community Support
Community Support

hi  @mrpowrbihelp 

You need to use ALLSELECTED instead of ALL in the rank measure

http://tinylizard.com/all-vs-allselected/

 

If you still have the problem, please share the sample pbix file and your expected output.

 

Regards,

Lin

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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