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
Ritesh_Air
Post Patron
Post Patron

RankX and filter certain amounts

Hi,

 

I want to rank certain things and exclude something which is below threshold. This below formulas works fine.

Product Marketing Brand asc = 
VAR PRODCUTRANKX =
    RANKX (
        ALL ( 'Product'[Product Marketing Brand] ),
        CALCULATE ( [Net Sales]),
        ,
        ASC,
        DENSE
    )
RETURN
    PRODCUTRANKX

 

But when I put Net Sales > 1000 then I get error.  How do I filter where I see brand's where Net Sales is above certain threshold and then rank accordingly?

 

RankX Brand.PNG

Here is the formula for Net Sales.

Net Sales =
CALCULATE (
    SUM ( 'Sales Order Detail'[Net Price Amount] ),
    'Sales Order Detail'[Open Order Indicator] = 0
)

 

 Thanks,

Ritesh

1 ACCEPTED SOLUTION

Hi @Ritesh_Air ,

 

Would you please refer to the following measure:

 

Product Marketing Brand asc =
VAR PRODCUTRANKX =
    IF (
        [Net Sales] > 1000,
        RANKX (
            FILTER ( ALL ( 'Product'[Product Marketing Brand] ), [Net Sales] > 1000 ),
            CALCULATE ( [Net Sales] ),
            ,
            ASC,
            DENSE
        ),
        BLANK ()
    )
RETURN
    PRODCUTRANKX

 

 

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

 

Best Regards,

Dedmon Dai

View solution in original post

6 REPLIES 6
parry2k
Super User
Super User

@Ritesh_Air you didn't explain what is the error



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

You are going to make a better man out of me. :).

 

Here is what I have highlighted in Yellow. 

Net Measures is not a physical table but just a group of all the measures.

 

Net Measures.PNGRankX Adding a Filter.PNG

 

Thanks,

Ritesh

@Ritesh_Air not sure what you are trying to achieve but after FILTER that ill the name of the actual data table, not the name of the table in which you have added the measure, Keep in mind measures are global across the model.

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2k 

 

Thanks Parry. But my actual measure "Net Sales" is here, which is a combination of a using 2 tables.

Net Sales =
CALCULATE (
    SUM ( 'Sales Order Detail'[Net Price Amount] ),
    'Sales Order Detail'[Open Order Indicator] = 0
)

  From there I am creating "Net Sales CY" as: 

Net Sales CY = 
var _Year = CALCULATE(MAX('Date'[Year Key]),ALL('Date'))
return
CALCULATE([Net Sales], 'Date'[Year Key] = _Year)

Then I am ranking as:

 

RankX Brand.PNG 

 

with this formula:

 

Product Marketing Brand asc = 
VAR PRODCUTRANKX =
    RANKX (
        ALL ( 'Product'[Product Marketing Brand] ),
        CALCULATE ( [Net Sales]),
        ,
        ASC,
        DENSE
    )
RETURN
    PRODCUTRANKX

 

Now as my original question:

If I want to filter my Rank table as "Net Sales" > 1000, how do I do that?

Thanks,

Ritesh

 

Hi @Ritesh_Air ,

 

Would you please refer to the following measure:

 

Product Marketing Brand asc =
VAR PRODCUTRANKX =
    IF (
        [Net Sales] > 1000,
        RANKX (
            FILTER ( ALL ( 'Product'[Product Marketing Brand] ), [Net Sales] > 1000 ),
            CALCULATE ( [Net Sales] ),
            ,
            ASC,
            DENSE
        ),
        BLANK ()
    )
RETURN
    PRODCUTRANKX

 

 

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

 

Best Regards,

Dedmon Dai

@v-deddai1-msft 

 

Thanks. This is exactly what I was looking for.

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.