Forum Discussion
ranking over virtual table
Hi, I want to create a ranking based on my virtual table. The aim of this analysis is to use the data from a virtual table to create a ABC analysis. for now I'm tryng to abstract and at least create a ranking
EVALUATE
VAR id_franchise_group = 99
VAR GRP = SUMMARIZE(
FILTER(
dim_store,[id_franchise_group] = id_franchise_group
),
dim_store'[FullName],
"value", CALCULATE(sum(fact_table'[price]))),
"amount", CALCULATE(sum(fact_table[price]),ALLSELECTED(dim_store[FullName]))
))
//RETURN GRP
VAR Total = ADDCOLUMNS(GRP,"RANKING",RANKX(all(GRP[FullName]),CALCULATE(sum(GRP[value]),,DESC,SKIP)))
RETURN Total
basically I'm trying to create a table with a value per store and ranking it
| FullName | Value | Amount | Ranking |
| store A | 30 | 50 | 1 |
| store B | 15 | 50 | 2 |
| Store C | 5 | 50 | 3 |
I just trying to use a virtual table after summarize to abstratct the Idea, but looks like I'm not able to use a virtual table with ranking function.
Some Idea?
Thanks
Hi Anonymous
I just modify your codes by correcting some pairs of single quotes and parentheses, and they seem work well.
EVALUATE VAR id_franchise_group = 99 VAR GRP = SUMMARIZE ( FILTER ( dim_store, [id_franchise_group] = id_franchise_group ), dim_store[FullName], "value", CALCULATE ( SUM ( fact_table[price] ) ), "amount", CALCULATE ( SUM ( fact_table[price] ), ALLSELECTED ( dim_store[FullName] ) ), "RANKING", RANKX ( ALL ( dim_store[fullname] ), CALCULATE ( SUM ( fact_table[price] ) ), , DESC, SKIP ) ) RETURN GRPRegards,
Community Support Team _ Jing
If this post helps, please Accept it as the solution to help other members find it.
3 Replies
- Ashish_Mathur
Super User
Hi,
Why not rank on an actual table instead?
- AnonymousNot applicable
when I do in a actual table something goes wrong, despite that I need to work with this table after to make some calculations:
EVALUATE VAR id_franchise_group = 99 VAR GRP = SUMMARIZE( FILTER( dim_store,[id_franchise_group] = id_franchise_group ), dim_store'[FullName], "value", CALCULATE(sum(fact_table'[price]))), "amount", CALCULATE(sum(fact_table[price]),ALLSELECTED(dim_store[FullName]) "RANKING",RANKX(all(dim_store[fullname]),CALCULATE(sum(fact_table'[price]),,DESC,SKIP)) ) RETURN GRPand now my ranking is duplicating
- v-jingzhang
Community Support
Hi Anonymous
I just modify your codes by correcting some pairs of single quotes and parentheses, and they seem work well.
EVALUATE VAR id_franchise_group = 99 VAR GRP = SUMMARIZE ( FILTER ( dim_store, [id_franchise_group] = id_franchise_group ), dim_store[FullName], "value", CALCULATE ( SUM ( fact_table[price] ) ), "amount", CALCULATE ( SUM ( fact_table[price] ), ALLSELECTED ( dim_store[FullName] ) ), "RANKING", RANKX ( ALL ( dim_store[fullname] ), CALCULATE ( SUM ( fact_table[price] ) ), , DESC, SKIP ) ) RETURN GRPRegards,
Community Support Team _ Jing
If this post helps, please Accept it as the solution to help other members find it.