Forum Discussion
Ang0zyx
4 years agoFrequent Visitor
DAX code to filter topn
Hi everyone, Could you please help me to convert the below query to dax.the idea is to filter the overall top3 products and show for all countries. SQL: Select country,product,sales from SalesT...
Jihwan_Kim
Super User
4 years agoHi,
I am not sure how your data model looks like or how your desired outcome looks like, but please try the below.
new measure: =
CALCULATE (
SUM ( SalesTable[sales] ),
KEEPFILTERS (
TOPN (
3,
ALLSELECTED ( SalesTable[product] ),
CALCULATE ( SUM ( SalesTable[sales] ) ), DESC
)
)
)