Forum Discussion
Korekar27
Helper I
2 years agoPower bi Dax
I have a scenario in Power bi where in Top 5,10,15 Product and city by sales and create a filter for top and bottom where in if I click on top I can see top 5,10,15 when I click on any of top 5,top 1...
Anonymous
2 years agoNot applicable
Hi Korekar27 ,
Please try like:
Ranking =
VAR topproduct =
RANKX ( ALL ( Products ), [Total Sales],, DESC )
VAR bottomproduct =
RANKX ( ALL ( Products ), [Total Sales],, ASC )
VAR topcity =
RANKX ( ALL ( 'India City Lat Long' ), [Total Sales],, DESC )
VAR bottomcity =
RANKX ( ALL ( 'India City Lat Long' ), [Total Sales],, ASC )
VAR ranking =
IF (
CONTAINSSTRING ( SELECTEDVALUE ( Breakdown[Breakdown Fields] ), "Products" ),
IF ( SELECTEDVALUE ( TopBottom[Value] ) = "Top", topproduct, bottomproduct ),
IF ( SELECTEDVALUE ( TopBottom[Value] ) = "Top", topcity, bottomcity )
)
VAR result =
IF (
HASONEVALUE(Products) || HASONEVALUE('India City Lat Long'),
IF ( ranking <= 'Ranking Option'[Ranking Option Value], [Total Sales] ),
CALCULATE([Total Sales], ALL(Products), ALL('India City Lat Long'))
)
RETURN result
Please try this and see if it works for your scenario. If not, please provide more details (No private data) about your data model.
How to provide sample data in the Power BI Forum
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
Korekar27
Helper I
2 years agoHi I tried the dax but now the same total is coming for Product and Region for Top and Bottom.