Forum Discussion
sqlguru448
Helper III
5 years agoRanking measure with Table variable
Hello Folks, I'm trying to create measure for Top 10 customers based on sales amount in Power BI which is connected Live to the Tabular model. Customer is Dimension and Sales amount is in fa...
- 5 years ago
Hi sqlguru448 ,
Be aware that making a summarizaition of a full table will bring for sure performance issues, in your case you are using the FACT table that I assume have a huge number of data so be aware of that.
Try the following code:
Measure = var temp_table = FILTER ( SUMMARIZE ( ALLSELECTED ( Customer[Name] ); Customer[Name]; "Total_Sales"; [Sales Amount] ); [Sales Amount] > 0 ) var Ranking = RANKX(temp_table; [Sales Amount]) RETURN RankingThen filter out all rankings above 10.
v-lili6-msft
Community Support
5 years agoHI sqlguru448
Try to use this formula to create a measure
Measure 2 =
VAR _RANK= RANKX (
ALLSELECTED ( Customer[Name] ),
CALCULATE ( SUM ( 'Fact'[Sales Amount] ) ))
RETURN
IF ( _RANK <= 10, _RANK)
if not your case, please share some simple sample data and your expected output.
Regards,
Lin
MFelix
Super User
5 years ago