Forum Discussion
Anonymous
5 years agoNot applicable
Measures into Columns - Dynamic Grouping based on window context problem
I have a dataset that I'd like to visualize with a dynamic legend - taking the groups with the 7 max individual values in my window context, showing them as they are, then grouping the rest into one ...
v-deddai1-msft
5 years agoCommunity Support
Hi Anonymous ,
If you are calculating topn + others by max of daily value, Please refer to the following steps. First create a new table for x-axis or table visuals:
Table = UNION(VALUES(Sheet1[Value]),ROW("Value","Group"))
Create an inactive relationship between your Sheet1 and the new table .Then you can use the following meaure for topn+others:
Topn + Groups =
VAR N = 1
VAR A =
SELECTEDVALUE ( 'Table'[Value] )
VAR stable =
SUMMARIZE (
Sheet1,
Sheet1[Value],
Sheet1[Date],
"amount", SUM ( Sheet1[Amount] )
)
VAR mtable =
SUMMARIZE (
Sheet1,
Sheet1[Value],
"maxofdailyvalue", MAXX ( FILTER ( stable, Sheet1[Value] = EARLIER ( Sheet1[Value] ) ), [amount] )
)
VAR topntable =
CALCULATETABLE (
VALUES ( Sheet1[Value] ),
TOPN ( N, mtable, [maxofdailyvalue] )
)
RETURN
IF (
A = "Group",
VAR allvalue =
SUMX ( mtable, [maxofdailyvalue] )
VAR topnvalue =
SUMX ( FILTER ( mtable, Sheet1[Value] IN topntable ), [maxofdailyvalue] )
RETURN
allvalue - topnvalue,
CALCULATE (
[MaxOfDailyValue],
FILTER ( 'Table', 'Table'[Value] IN topntable ),
USERELATIONSHIP ( Sheet1[Value], 'Table'[Value] )
)
)
For more details, please refer to the pbix file: https://qiuyunus-my.sharepoint.com/:u:/g/personal/pbipro_qiuyunus_onmicrosoft_com/EQluOjFu69FKhIdbT6h4PDgBPyhrxHEMVA66NYvdKgpkaQ?e=fW9pnW
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Best Regards,
Dedmon Dai