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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
satyanarayan
New Member

Create new table with the help of existing one

Hi

My requirment is as per follwing. I have a table daily Production, so i need to find stopage reason in row table as per given example.

 

DateProduction LineProduction QtyTotal Machine TimeUnitStopage time 1UnitReason For Stopage 1Stopage time 2UnitReason For Stopage 2
01-Jan-2010001 cream1400200MIN50MINElectrical Problem20MinMachanical Problem

 I Want as per follwing new table

DateProduction LineProduction QtyTotal Machine TimeUnitStopage time 1UnitReason For Stopage 1
01-Jan-2010001 cream1400200MIN50MINElectrical Problem
01-Jan-2010001 cream1400200MIN20MinMachanical Problem

 

Thank in advance

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Use the UNPIVOT function in Power Query.

Best
D

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjDU9UrM0zUyUNJRMjQwMDBUSC5KTcwF8UwMQIJGYNLX0w9ImiKYrjmpySVFmcmJOQoBRflJOam5YLUg+cw8EJmYnJGYhyIfGwsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, #"Production Line" = _t, #"Production Qty" = _t, #"Total Machine Time" = _t, Unit = _t, #"Stopage time 1" = _t, Unit.1 = _t, #"Reason For Stopage 1" = _t, #"Stopage time 2" = _t, Unit.2 = _t, #"Reason For Stopage 2" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Production Line", type text}, {"Production Qty", Int64.Type}, {"Total Machine Time", Int64.Type}, {"Unit", type text}, {"Stopage time 1", Int64.Type}, {"Unit.1", type text}, {"Reason For Stopage 1", type text}, {"Stopage time 2", Int64.Type}, {"Unit.2", type text}, {"Reason For Stopage 2", type text}}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Date", "Production Line", "Production Qty", "Total Machine Time", "Unit", "Stopage time 1", "Unit.1", "Stopage time 2", "Unit.2"}, "Attribute", "Value"),
    #"Unpivoted Columns1" = Table.UnpivotOtherColumns(#"Unpivoted Columns", {"Date", "Production Line", "Production Qty", "Total Machine Time", "Unit", "Unit.1", "Unit.2", "Attribute", "Value"}, "Attribute.1", "Value.1"),
    #"Added Custom" = Table.AddColumn(#"Unpivoted Columns1", "Should Keep", each (Text.Contains([Attribute], "1") and Text.Contains([Attribute.1], "1")) or (Text.Contains([Attribute], "2") and Text.Contains([Attribute.1], "2"))),
    #"Filtered Rows" = Table.SelectRows(#"Added Custom", each ([Should Keep] = true)),
    #"Renamed Columns" = Table.RenameColumns(#"Filtered Rows",{{"Value", "Reason For Stoppage"}, {"Value.1", "Stoppage Time"}}),
    #"Removed Columns" = Table.RemoveColumns(#"Renamed Columns",{"Attribute", "Attribute.1", "Should Keep", "Unit.1", "Unit.2"})
in
    #"Removed Columns"

 

Just paste into Power Query and see step by step how it works. Then adjust to your requirements.

 

Best

D

code paste in query it work. but when add more line item in table1 result of table 2 is not changed. it is alway stastic. 

Anonymous
Not applicable

Use the UNPIVOT function in Power Query.

Best
D

Can you explain how to use this fuction on this table.

As suggested, i tried the same. But it is not working.

I am also having the same issue.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.