The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi,
I am trying to build a rank function by which I can achieve the top 5 countries by Sales, but when I add in the month column it shows me the top 5 countries each month whereas the expectation is to get the top5 countries and then split the value across the month to plot it on the line graph.
DAX used as of now :
Below is the screenshot for reference:
Current Output -
Expected Output:
@parry2k @amitchandak @Ritaf1983 @lbendlin
Solved! Go to Solution.
Hi @Anonymous ,
Please try like:
Ranking =
IF (
NOT ISBLANK ( SELECTEDVALUE ( 'Orders'[State] ) ),
RANKX (
ALL ( 'Orders'[State] ),
CALCULATE ( [Total Sales], ALL ( 'Orders'[Month] ) ),
,
DESC,
DENSE
)
)
The top five can then be tagged as needed:
Measure = IF([Ranking]<=5,1,0)
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
Hi @Anonymous , thanks a lot for the solution its working fine.
Can you please help me understand the reason for adding the selected value Dax condition?
IF ( NOT ISBLANK ( SELECTEDVALUE ( 'Orders'[State] ) ),
Here the solution could be to add a filter field to the RANKX ( all ( Orders [Status] )&&all([Month]), [Total Sales] , DESC )
Hi @Anonymous ,
Please try like:
Ranking =
IF (
NOT ISBLANK ( SELECTEDVALUE ( 'Orders'[State] ) ),
RANKX (
ALL ( 'Orders'[State] ),
CALCULATE ( [Total Sales], ALL ( 'Orders'[Month] ) ),
,
DESC,
DENSE
)
)
The top five can then be tagged as needed:
Measure = IF([Ranking]<=5,1,0)
Best Regards,
Gao
Community Support Team
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data in the Power BI Forum
User | Count |
---|---|
77 | |
75 | |
36 | |
31 | |
29 |
User | Count |
---|---|
93 | |
81 | |
57 | |
48 | |
48 |