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
Anonymous
Not applicable

Transforming data table

Hi,

 

In PowerBI i have a data Table 1, which needs to be converted a in Table 2.

Is it possible? Thanks in advance for your help.

 

Table 1:
Table 1 (from)Table 1 (from)

 

Table 2:
Table 2 (to)Table 2 (to)

 

BR,

Anabn

1 ACCEPTED SOLUTION
slorin
Super User
Super User

Hi,

 

let
Source = Your_Source,
Unpivot = Table.UnpivotOtherColumns(Source, {"ID", "Activity"}, "Attribute", "Value"),
Combine_Columns = Table.CombineColumns(Unpivot,{"Activity", "Attribute"},Combiner.CombineTextByDelimiter("_", QuoteStyle.None),"Attribute.1"),
Pivot = Table.Pivot(Combine_Columns, List.Distinct(Combine_Columns[Attribute.1]), "Attribute.1", "Value",
each Text.Combine(List.Transform(_, Text.From), " - "))
in
Pivot

Stéphane

View solution in original post

5 REPLIES 5
slorin
Super User
Super User

Hi,

 

let
Source = Your_Source,
Unpivot = Table.UnpivotOtherColumns(Source, {"ID", "Activity"}, "Attribute", "Value"),
Combine_Columns = Table.CombineColumns(Unpivot,{"Activity", "Attribute"},Combiner.CombineTextByDelimiter("_", QuoteStyle.None),"Attribute.1"),
Pivot = Table.Pivot(Combine_Columns, List.Distinct(Combine_Columns[Attribute.1]), "Attribute.1", "Value",
each Text.Combine(List.Transform(_, Text.From), " - "))
in
Pivot

Stéphane

wdx223_Daniel
Super User
Super User

=Table.Combine(Table.Group(PreviousStepName,"ID",{"n",each let a=List.Skip(Table.ColumnNames(_),2) in #table({"ID"}&List.TransformMany([Activity],each a,(x,y)=>x&"_"&y),{List.Combine(Table.Rows(Table.SelectColumns(_,a)))})})[n])

slorin
Super User
Super User

Hi,

let
Source = Your_Source,
Unpivot = Table.UnpivotOtherColumns(Source, {"ID", "Activity"}, "Attribute", "Value"),
Combine_Columns = Table.CombineColumns(Unpivot,{"Activity", "Attribute"},Combiner.CombineTextByDelimiter("_", QuoteStyle.None),"Attribute.1"),
Pivot = Table.Pivot(Combine_Columns, List.Distinct(Combine_Columns[Attribute.1]), "Attribute.1", "Value")
in
Pivot

Stéphane 

Anonymous
Not applicable

Hi, Thank you 🙂
this worked perfectly fine.
But some values have Error after Pivot, even though it had a proper date format before pivot.
ErrorError

ppm1
Solution Sage
Solution Sage

You could do it by first unpivoting the Date 1, Date 2, and Date 3 columns, create a new column that merges the first column with the new Attribute column (Date 1/2/3), and then pivoting on that new column. However, you should consider just doing the unpivot step only to set your data up for easier analysis (you could always create your design table in a visual as needed).

 

Pat

Microsoft Employee

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.