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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

Reply
hegler23
Frequent Visitor

Advanced Unpivoting Power Query

INPUT.jpgErgebnis.jpg

1 ACCEPTED SOLUTION
PwerQueryKees
Super User
Super User

 

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Datum", type date}, {"Benutzer", type text}, {"Menge", type text}, {"ME", type text}}),
    #"Pivoted Column" = Table.Pivot(#"Changed Type", List.Distinct(#"Changed Type"[Benutzer]), "Benutzer", "Menge", each Text.Combine(_, ","))
in
    #"Pivoted Column"

 

 

PwerQueryKees_1-1733083603670.png

 

 

 

View solution in original post

4 REPLIES 4
lbendlin
Super User
Super User

That is pivoting, not unpivoting.  And it will result in variable number of columns which is something neither Power Query nor Power BI will be happy about.

lbendlin_0-1733083895456.png

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjbQMzTUMzIwMlHSUQoKDweSpgZAwttdKVZn5EobWSJJe4cHAUlDc9NReazykOCjn3wsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Datum = _t, Benutzer = _t, Menge = _t, ME = _t]),
    #"Grouped Rows" = Table.Group(Source, {"Datum", "ME", "Benutzer"}, {{"Values", each Text.Combine(_[Menge],",")}}),
    #"Pivoted Column" = Table.Pivot(#"Grouped Rows", List.Distinct(#"Grouped Rows"[Benutzer]), "Benutzer", "Values")
in
    #"Pivoted Column"

How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done". Once you examined the code, replace the entire Source step with your own source.

 

Vielen Dank für die Lösung

PwerQueryKees
Super User
Super User

 

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Datum", type date}, {"Benutzer", type text}, {"Menge", type text}, {"ME", type text}}),
    #"Pivoted Column" = Table.Pivot(#"Changed Type", List.Distinct(#"Changed Type"[Benutzer]), "Benutzer", "Menge", each Text.Combine(_, ","))
in
    #"Pivoted Column"

 

 

PwerQueryKees_1-1733083603670.png

 

 

 

Vielen Dank für die Lösung

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.