Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
aaron797
Advocate I
Advocate I

Pivot Measures in Powerbi

Hi,

 

I have the below "measures" in powerBI that are calculated post data load.

 

EngagedDisengagedActivelyDisengaged
3671

 

I would like to pivot them into the below columns, is anyone able to provide some tips on how i would approach this?

 

EngagementCountEngagement
Engaged36
Disengaged7
Actively Disengaged1

 

The end goal is to take the above columns into a pie chart.

 

Thank you!

2 ACCEPTED SOLUTIONS

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]))
)

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

View solution in original post

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])

 

3.jpg

 


Best regards,

 

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

7 REPLIES 7
amitchandak
Super User
Super User

Refer if this can help

 

https://radacad.com/pivot-and-unpivot-with-power-bi

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
https://community.powerbi.com/t5/Community-Blog/Winner-Topper-on-Map-How-to-Color-States-on-a-Map-wi...
https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...
https://community.powerbi.com/t5/Community-Blog/Power-BI-Working-with-Non-Standard-Time-Periods/ba-p...
https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Hi, Don't think i can use the query editor to transform as these are measures.

A bit time-consuming way but the union and summarize can do

 

Summary = UNION(
SUMMARIZE('Table1','Table1'[Customer],'Table1'[created_date],'Table1'[DA Status],"Sales",sum('Table1'[Sales]),"Invoices",count('Table1'[ID]),"Time",DIVIDE(SUM('Table1'[Ship Time]),1),"Stage"," Ship","Gross",sum('Table1'[inv_amount]),"Net",Sum('Table1'[Net Calc Amount]))
,SUMMARIZE('Table2','Table2'[Customer],'Table1'[created_date],'Table2'[AA Status],"Sales",sum('Table2'[Sales]),"Invoices",count('Table2'[ID]),"Time",DIVIDE(SUM('Table1'[Order Time]),1),"Stage","Order","Gross",sum('Table1'[inv_amount]),"Net",Sum('Table1'[Net Calc Amount]))
)

 

Here "Stage","Order" and "Stage","Ship" are static columns created. You will union for each measure and the use static column to put the name of the measure.

All groups by will come without the name, followed by grouped data with name , formula

and static name, disp name

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
https://community.powerbi.com/t5/Community-Blog/Winner-Topper-on-Map-How-to-Color-States-on-a-Map-wi...
https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...
https://community.powerbi.com/t5/Community-Blog/Power-BI-Working-with-Non-Standard-Time-Periods/ba-p...
https://community.powerbi.com/t5/Community-Blog/Comparing-Data-Across-Date-Ranges/ba-p/823601

 

 

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Hi Amit,

 

Thank you for the reply, I am having issues breaking down the below code, it is a bit beyond me, for instance DA Status/AA Status, Net Cal Amount etc. 

 

it would be greatly appreciated if you prepare the union statement with my columns above, or provide some further resources / explanation. 

 

Thank you very much!!

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])

 

3.jpg

 


Best regards,

 

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

This worked perfectly, thank you! very simple approach.

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]))
)

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.