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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Jase68
Helper I
Helper I

Transpose a table

Hi PBI Experts

 

I habe a simple table that I need to transpose so that the DATES (Year-Wk) move from the rows to the columns.

 

This is my current format;

 

Year-Week MeasureID Value
2020-01     A                 5
2020-02     A                10
2020-01     B                15
2020-02     B                20


I want to transpose on load so I get the data into a table that looks like this;

 

MeasureID      2020-01      2020-02
A                     5                10
B                     15              20

 

I have tried many ways but I cannot get it to work.   It feels like there should be a simple answer so hoping someone can help...

4 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

Refer, if pivot  can help

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

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

Greg_Deckler
Community Champion
Community Champion

Here is the Power Query version:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtA1MFTSUXIEYlOlWB2YmBFUzNAASRCk0AkkiK4SJGgEVBkLAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"Year-Week" = _t, MeasureID = _t, Value = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Year-Week", type date}, {"MeasureID", type text}, {"Value", Int64.Type}}),
    #"Pivoted Column" = Table.Pivot(Table.TransformColumnTypes(#"Changed Type", {{"Year-Week", type text}}, "en-US"), List.Distinct(Table.TransformColumnTypes(#"Changed Type", {{"Year-Week", type text}}, "en-US")[#"Year-Week"]), "Year-Week", "Value", List.Sum)
in
    #"Pivoted Column"


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

Anonymous
Not applicable

@Jase68 

Query Editor => Pivot column

 

Pivot.JPG

 

Paul Zheng
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

Vera_33
Resident Rockstar
Resident Rockstar

Hi @Jase68  select the first two columns and pivot the value column in Power Query

Capture.PNG

 

 

View solution in original post

9 REPLIES 9
Vera_33
Resident Rockstar
Resident Rockstar

Hi @Jase68  select the first two columns and pivot the value column in Power Query

Capture.PNG

 

 

Works a treat - thanks!

Anonymous
Not applicable

@Jase68 

Query Editor => Pivot column

 

Pivot.JPG

 

Paul Zheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

This works - thanks!

Greg_Deckler
Community Champion
Community Champion

Here is the Power Query version:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtA1MFTSUXIEYlOlWB2YmBFUzNAASRCk0AkkiK4SJGgEVBkLAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"Year-Week" = _t, MeasureID = _t, Value = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Year-Week", type date}, {"MeasureID", type text}, {"Value", Int64.Type}}),
    #"Pivoted Column" = Table.Pivot(Table.TransformColumnTypes(#"Changed Type", {{"Year-Week", type text}}, "en-US"), List.Distinct(Table.TransformColumnTypes(#"Changed Type", {{"Year-Week", type text}}, "en-US")[#"Year-Week"]), "Year-Week", "Value", List.Sum)
in
    #"Pivoted Column"


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Brilliant - thank you.

Greg_Deckler
Community Champion
Community Champion

I wrote a DAX Transpose once: https://community.powerbi.com/t5/Quick-Measures-Gallery/TRANSPOSE/m-p/630229#M314


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
amitchandak
Super User
Super User

Refer, if pivot  can help

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

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Yes, this worked. Thanks.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.