Forum Discussion
RANKX doesnt work as It should
- 1 year ago
Hi lucie_raboch based on my understanding on the data model, here is the calculated table , please test it if it works, not able to upload pbix file
TopMasterTable =VAR BaseTable =SUMMARIZE('Master_Unique','Master_Unique'[Master])VAR SalesWithValues =ADDCOLUMNS(BaseTable,"Sales",CALCULATE(SUM('FactVarMetrics'[Value]),'DimSce'[Scenario] = "Budget",'DimSce'[Metric] = "Gross",TREATAS(VALUES('Master_Unique'[Master]), 'DimProducts'[Master])))VAR WithRank =ADDCOLUMNS(SalesWithValues,"Sales Rank",RANKX(SalesWithValues,[Sales],,DESC,DENSE))RETURNADDCOLUMNS(WithRank,"MasterGroup",IF([Sales Rank] <= 20, [Master], "Others"))
Hi,
Ranking is working now, but I need to remove Master from the table to see only top 20 rows and Others and if I remove Master Column then Master Group is BLANK.
Also how can I sort according to the Rank?
- techies1 year ago
Super User
Hi lucie_raboch does creating a calculated table and using its columns in a table visual work for you?
like this
TopMasterTable =ADDCOLUMNS(SUMMARIZE('Sheet9', 'Sheet9'[Master]),"Sales", [Sales amount],"Sales Rank", RANKX(ALL('Sheet9'[Master]),[Sales amount],,DESC,DENSE),"MasterGroup",VAR CurrentRank =RANKX(ALL('Sheet9'[Master]),[Sales amount],,DESC,DENSE)RETURNIF(CurrentRank <= 20, 'Sheet9'[Master], "Others"))- lucie_raboch1 year ago
Helper II
This is my PowerBI file: https://drive.google.com/file/d/1HagYTmRAdT6SFQd1HXw7CM10jwrFFOcy/view?usp=sharing
Can you create this table in this file and share back please?
Because it's not working properly and I don't know why.
- techies1 year ago
Super User
Hi lucie_raboch based on my understanding on the data model, here is the calculated table , please test it if it works, not able to upload pbix file
TopMasterTable =VAR BaseTable =SUMMARIZE('Master_Unique','Master_Unique'[Master])VAR SalesWithValues =ADDCOLUMNS(BaseTable,"Sales",CALCULATE(SUM('FactVarMetrics'[Value]),'DimSce'[Scenario] = "Budget",'DimSce'[Metric] = "Gross",TREATAS(VALUES('Master_Unique'[Master]), 'DimProducts'[Master])))VAR WithRank =ADDCOLUMNS(SalesWithValues,"Sales Rank",RANKX(SalesWithValues,[Sales],,DESC,DENSE))RETURNADDCOLUMNS(WithRank,"MasterGroup",IF([Sales Rank] <= 20, [Master], "Others"))