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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
sabd80
Helper III
Helper III

Power Query pivot

Hi,
I have below data in Power BI:


Table.png

 

I would like to pivot the data to below in another table:

Pivot.png

 

How can I do that?

1 ACCEPTED SOLUTION
govind_021
Resolver I
Resolver I

Hi , @sabd80 
Please , follow below steps
1) Select Volume , Gross Value , Net Value column with help of ctrl key 
then go to "Transform" and select unpivot columns then Unpivot only Selected columns 

govind_021_0-1733809225555.png

then your data will look like this 

govind_021_1-1733809260304.png

2) After That select source and  attribute column with ctrl key together and go to trasnform and select
merge columns and in separator choose space from the option.


Then your data will look like this 

govind_021_3-1733809484873.png

3)  After that select Newly merged column

govind_021_4-1733809540065.png

and click on Transform data "Pivot" and in value section select Value column
and your data will be in desired state 

govind_021_5-1733809611249.png

 

Best Regards,
Govind Sapkade
Data Analyst | Power BI Enthusiast | Microsoft PL 300 Certified Power BI Data Analyst | MS Fabric Enthusiast
🎥Subscribe to my youtube channel for hands on tutorials : YouTube

📊Let’s connect on Linkdin : Linkdin

 

View solution in original post

7 REPLIES 7
v-sgandrathi
Community Support
Community Support

Hi, @sabd80 
Thanks for reaching out to the Microsoft Fabric Community forum

 

I trust the @govind_021 response is accurate and will address your issue.

If you have any further questions or updates regarding your issue, feel free to ask, and we will look into that.

If the Super User's answer meets your requirements, please consider marking it as the Accepted solution.

 

Regards,
Sahasra

Tahreem24
Super User
Super User

@sabd80 You could try with matrix visual with below settings:

 

Tahreem24_0-1733811452083.png

 

 

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

@Tahreem24 , I am aware of that, I meant it on the row level. But thanks for your reply.

govind_021
Resolver I
Resolver I

Hi , @sabd80 
Please , follow below steps
1) Select Volume , Gross Value , Net Value column with help of ctrl key 
then go to "Transform" and select unpivot columns then Unpivot only Selected columns 

govind_021_0-1733809225555.png

then your data will look like this 

govind_021_1-1733809260304.png

2) After That select source and  attribute column with ctrl key together and go to trasnform and select
merge columns and in separator choose space from the option.


Then your data will look like this 

govind_021_3-1733809484873.png

3)  After that select Newly merged column

govind_021_4-1733809540065.png

and click on Transform data "Pivot" and in value section select Value column
and your data will be in desired state 

govind_021_5-1733809611249.png

 

Best Regards,
Govind Sapkade
Data Analyst | Power BI Enthusiast | Microsoft PL 300 Certified Power BI Data Analyst | MS Fabric Enthusiast
🎥Subscribe to my youtube channel for hands on tutorials : YouTube

📊Let’s connect on Linkdin : Linkdin

 

@govind_021  thank you so much for your solution, it worked perfectly.

Irwan
Memorable Member
Memorable Member

hello @sabd80 

 

here is just a simple example just to give rough idea.

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("VYq7DYAwDAV3eXUKf8QAsIblIgREQ5nsj60UEc2ddDozMDMKamIjohDTcua99VFfeDGISIQzIXMSWpb/rKoRWkLnpLSc+RjXc3e4fw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, Product = _t, Volume = _t, Gross = _t, Net = _t, Source = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Product", type text}, {"Volume", Int64.Type}, {"Gross", Int64.Type}, {"Net", Int64.Type}, {"Source", type text}}),
#"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"ID", "Product", "Source"}, "Attribute", "Value"),
#"Merged Columns" = Table.CombineColumns(#"Unpivoted Columns",{"Source", "Attribute"},Combiner.CombineTextByDelimiter(" ", QuoteStyle.None),"Merged"),
#"Merged Columns1" = Table.CombineColumns(Table.TransformColumnTypes(#"Merged Columns", {{"ID", type text}}, "en-ID"),{"ID", "Product"},Combiner.CombineTextByDelimiter(" ", QuoteStyle.None),"Merged.1"),
#"Pivoted Column" = Table.Pivot(#"Merged Columns1", List.Distinct(#"Merged Columns1"[Merged]), "Merged", "Value", List.Sum),
#"Split Column by Delimiter" = Table.SplitColumn(#"Pivoted Column", "Merged.1", Splitter.SplitTextByDelimiter(" ", QuoteStyle.Csv), {"Merged.1.1", "Merged.1.2"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Merged.1.1", Int64.Type}, {"Merged.1.2", type text}})
in
#"Changed Type1"

here are the steps:

1. Unpivot the table

Irwan_0-1733809341574.png

 

2. Merge so you get your header description

Irwan_1-1733809367120.png

 

3. Merge ID and product since you dont want to those columns get pivoted

Irwan_2-1733809399329.png

 

4. Pivot back the table

Irwan_3-1733809424132.png

 

5. Split ID and Product

Irwan_4-1733809446566.png

 

this might not the most efficient way, but you can tweak it to your need. Also, dont mind the null value because i didnot type all your data in screenshot.

 

otherwise, @danextian 's solution surely works

 

Hope this will help.
Thank you.

danextian
Super User
Super User

Hi @sabd80,

 

You will need to create several measures and add them to a PowerPivot  pivot table. Example:

Actual Volume =
CALCULATE (
    SUM ( 'table'[Volume] ),
    KEEPFILTERS ( 'table'[Source] = "Actual" )
)

 

 










Did I answer your question? Mark my post as a solution!


Proud to be a Super User!









"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

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