Forum Discussion
aaron797
Advocate I
6 years agoPivot Measures in Powerbi
Hi, I have the below "measures" in powerBI that are calculated post data load. Engaged Disengaged ActivelyDisengaged 36 7 1 I would like to pivot them into the below columns,...
- 6 years ago
Try this
union( SUMMARIZE(table, table[any Group by col], "Engagement","Engaged","CountEngagement" , sum(table[Engaged])), SUMMARIZE(table, table[any Group by col], "Engagement","Disengaged","CountEngagement" , sum(table[Disengaged])), SUMMARIZE(table, table[any Group by col], "Engagement","ActivelyDisengaged","CountEngagement" , sum(table[ActivelyDisengaged])) )or
union(
SUMMARIZE(table, "Engagement","Engaged","CountEngagement" , sum(table[Engaged])),
SUMMARIZE(table, "Engagement","Disengaged","CountEngagement" , sum(table[Disengaged])),
SUMMARIZE(table, "Engagement","ActivelyDisengaged","CountEngagement" , sum(table[ActivelyDisengaged]))
) - 6 years ago
Hi aaron797 ,
We can create a Calculated table to store the name of enagement, then we can create a measure to calculate the result of each measure:
Calculated Table:
Engagement = DATATABLE("Engagement",STRING,{{"Engaged"},{"Disengaged"},{"Actively Disengaged"}})Measures:
CountEngagement = SWITCH(SELECTEDVALUE(Engagement[Engagement]),"Engaged",[Engaged],"Disengaged",[Disengaged],"Actively Disengaged",[ActivelyDisengaged])
Best regards,
v-lid-msft
Community Support
6 years agoHi aaron797 ,
We can create a Calculated table to store the name of enagement, then we can create a measure to calculate the result of each measure:
Calculated Table:
Engagement = DATATABLE("Engagement",STRING,{{"Engaged"},{"Disengaged"},{"Actively Disengaged"}})
Measures:
CountEngagement = SWITCH(SELECTEDVALUE(Engagement[Engagement]),"Engaged",[Engaged],"Disengaged",[Disengaged],"Actively Disengaged",[ActivelyDisengaged])
Best regards,
aaron797
Advocate I
6 years agoThis worked perfectly, thank you! very simple approach.