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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Redraidas1
Helper I
Helper I

How to get TOP10

I'm trying to limit my DAX top give me the the SUM of TOP10 sales, however, DAX seems to be ignoring my TOP10 request and won't limit the caluclation to TOP 10 only. Any ideas? Thanks!
 
CALCULATE (
SUM ( AfterSales_BM[ABCValue] ),
TOPN( 10, AfterSales_BM, AfterSales_BM[ABCValue]),
FILTER (
Config,
Config[FieldCode] = "1"
  )
)
1 ACCEPTED SOLUTION
v-jayw-msft
Community Support
Community Support

Hi @Redraidas1 ,

 

You could consider to create a measure using RANKX() function.

Then add this measure to filter to filter the data that rank value is less than 10.

For example:

_sum = SUM('Table'[value])

_rank = RANKX(ALL('Table'),[_sum])

4.PNG 

 

Best Regards,

Jay

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

View solution in original post

5 REPLIES 5
v-jayw-msft
Community Support
Community Support

Hi @Redraidas1 ,

 

You could consider to create a measure using RANKX() function.

Then add this measure to filter to filter the data that rank value is less than 10.

For example:

_sum = SUM('Table'[value])

_rank = RANKX(ALL('Table'),[_sum])

4.PNG 

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
parry2k
Super User
Super User

@Redraidas1 it is not as straightforward as it looks like, you are doing top 10 on a table and also filtering on another table. Also what are your expectation when you are seeing the data below, let's say we want the top 3 (would you like to see (200 + 40 + 30, = 270 since these are top 3 values ), or you want it to sum by the customer and then take top 3 in that case from the data below the result will be (A = 15, B = 30, C = 200, D = 70 and top 3 will be then 200 + 70 + 30 = 300)

 

A - 10

A - 5

B - 20

B - 10

C - 200

D - 30

D - 40

 

It will be easier if you share pbix file using one drive/google drive with the expected output. Remove any sensitive information before sharing.



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.

VijayP
Super User
Super User

@Redraidas1 

Use this Function
VAR = RankofABC = Rankx(all(AfterSales_BM[ColumnName]),sum(abcvalue))
return
calculate(sum(abcvalue),filter(all(all(AfterSales_BM[ColumnName]),RankofABC<=10),distinct(columname))




Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


VijayP
Super User
Super User

@Redraidas1 

CALCULATE (
SUM ( AfterSales_BM[ABCValue] ),
TOPN( 10, AfterSales_BM, AfterSales_BM[ABCValue]),
FILTER (
Config,
Config[FieldCode] = "1"
  ),Distinct(ColumnName)
)
The bold one is which column you want to see the Rank (most probably AferSales_BM)?!
Please do let me know whether this helped!
 



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


I changed it, but the problem is still there.

DAX:

CALCULATE (
 
SUM ( AfterSales_BM[ABCValue] ),
TOPN( 5, AfterSales_BM, AfterSales_BM[ABCValue]),
FILTER (
Dim_Report_Config,
Dim_Report_Config[FieldCode] = "1"
), DISTINCT(AfterSales_BM[ABCValue])
)

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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