Forum Discussion
lucie_raboch
Helper II
1 year agoRANKX doesnt work as It should
Hi all, My goal is to show top 20 master by metric Sales and the rest will be grouped like 'Others'. I'm working with RANKX to be able rank values, but it is showing 11111 insted of 1,2,3,4,5. Ca...
- 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"))
techies
Super User
1 year agoHi 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
)
RETURN
IF(CurrentRank <= 20, 'Sheet9'[Master], "Others")
)
lucie_raboch
Helper II
1 year agoThis 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"))