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
Likhitha
Helper IV
Helper IV

TOP N with ALL DAX.

Hello All,

I'm having one small doubt , I applied ALL Filter in Caculating Sales.In matrix I projected ProductName and Sales and taken TOP 10 products based on sales(In Filter Pane).But with ALL Filter it's showing for all products not for TOP 10. I want 12,473,878 in Sales Rank Column.

How to sort it out?

Capture-ALL.PNG

2 ACCEPTED SOLUTIONS
Mariusz
Community Champion
Community Champion

Hi @Likhitha 

 

You can use the below pattern replacing Brand with product Name

 

Top n Brank = 
VAR __topn = 
    TOPN(
        10,
        CALCULATETABLE(
            VALUES( 'Product'[Brand] ), 
            ALLSELECTED()
        ), 
        [Sales], --Measure,
        DESC
    ) 
RETURN
CALCULATE(
    [Sales], --Measure,
    __topn
)

 

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn

 

View solution in original post

V-pazhen-msft
Community Support
Community Support

@Likhitha 

 

If you want find the Top 10 product based on the sales, you could use RANKX to give a rank to the Sales Amount.  Then filter with <=10. Something like:

 

Calculate(Sum(), Filter(Table, [rank]<=10).

 

You can share a sample of your model, it is difficult to provide a absolute solution just with your description.

 

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

 

 

View solution in original post

3 REPLIES 3
V-pazhen-msft
Community Support
Community Support

@Likhitha 

 

If you want find the Top 10 product based on the sales, you could use RANKX to give a rank to the Sales Amount.  Then filter with <=10. Something like:

 

Calculate(Sum(), Filter(Table, [rank]<=10).

 

You can share a sample of your model, it is difficult to provide a absolute solution just with your description.

 

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

 

 

Mariusz
Community Champion
Community Champion

Hi @Likhitha 

 

You can use the below pattern replacing Brand with product Name

 

Top n Brank = 
VAR __topn = 
    TOPN(
        10,
        CALCULATETABLE(
            VALUES( 'Product'[Brand] ), 
            ALLSELECTED()
        ), 
        [Sales], --Measure,
        DESC
    ) 
RETURN
CALCULATE(
    [Sales], --Measure,
    __topn
)

 

 

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn

 

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.