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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
Anonymous
Not applicable

Creating a new table using existing table

I have the below Query Table 

 

Table1

Car_ID

ShiftServiceTypeTimestamp
1011Water Wash; Bubble wash9/1/2021 12:00:00 PM
1021Air Wash9/1/2021 02:10:00 PM
1031Bubble Wash9/1/2021 02:40:00 PM
1012Interior Clean9/1/2021 04:05:00 PM

 

I want to create a new Table in Power Query for Service type and car and respective timestamp, Like below

 

Table2

Service TypeCar NoshiftTimestamp
Water Wash 10119/1/2021 12:00:00 PM
Bubble wash10119/1/2021 12:00:00 PM
Air wash10219/1/2021 02:10:00 PM
Bubble wash10319/1/2021 02:40:00 PM
Interior Clean10129/1/2021 04:05:00 PM

 

Steps I followed:

Created new Query with Servicetype

Changed it to table

Used delimeter as semicolon to split columns. (this created two columns)

Added a custom column ,  = #"Table1"

Expanded to get the CarNo, Shift, Timestamp.

-This is causing the data in second column to disappear.

Is there a better way to get the CarNo, Shift, Timestamp. to table 1?

 

I tried unpivoting and add the columns and didn't work to 

So thought to bring the columns first and then unpivot and that didn't work to.

 

Could anyone help in creating table2?

 

Thanks!

1 ACCEPTED SOLUTION
edhans
Community Champion
Community Champion

Does this work?

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQwVNJRAuHwxJLUIoXwxOIMawWn0qSknFSFciAHKGOpb6hvZGBkqGBoZGVgAEQKAb5KsTogzUZQzY6ZEK3Iqg2MrAxRVRtDVUONx6LBBFUDSDHICs88oNsy84sUnHNSE/NQ9JhYGZjC9MQCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Car ID" = _t, Service = _t, Type = _t, Timestamp = _t]),
    #"Split Column by Delimiter" = Table.SplitColumn(Source, "Type", Splitter.SplitTextByDelimiter(";", QuoteStyle.Csv), {"Type.1", "Type.2"}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Split Column by Delimiter", {"Car ID", "Service", "Timestamp"}, "Attribute", "Value"),
    #"Removed Other Columns" = Table.SelectColumns(#"Unpivoted Columns",{"Service", "Car ID", "Value", "Timestamp"})
in
    #"Removed Other Columns"


This:

edhans_0-1631216521319.png

becomes this:

edhans_1-1631216542319.png

You may need to rename the Values column. But it took the multiple possible values in the Type field and made them into their own row by splitting it then unpivoting it.

 

How to use M code provided in a blank query:
1) In Power Query, select New Source, then Blank Query
2) On the Home ribbon, select "Advanced Editor" button
3) Remove everything you see, then paste the M code I've given you in that box.
4) Press Done
5) See this article if you need help using this M code in your model.

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

1 REPLY 1
edhans
Community Champion
Community Champion

Does this work?

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQwVNJRAuHwxJLUIoXwxOIMawWn0qSknFSFciAHKGOpb6hvZGBkqGBoZGVgAEQKAb5KsTogzUZQzY6ZEK3Iqg2MrAxRVRtDVUONx6LBBFUDSDHICs88oNsy84sUnHNSE/NQ9JhYGZjC9MQCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Car ID" = _t, Service = _t, Type = _t, Timestamp = _t]),
    #"Split Column by Delimiter" = Table.SplitColumn(Source, "Type", Splitter.SplitTextByDelimiter(";", QuoteStyle.Csv), {"Type.1", "Type.2"}),
    #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Split Column by Delimiter", {"Car ID", "Service", "Timestamp"}, "Attribute", "Value"),
    #"Removed Other Columns" = Table.SelectColumns(#"Unpivoted Columns",{"Service", "Car ID", "Value", "Timestamp"})
in
    #"Removed Other Columns"


This:

edhans_0-1631216521319.png

becomes this:

edhans_1-1631216542319.png

You may need to rename the Values column. But it took the multiple possible values in the Type field and made them into their own row by splitting it then unpivoting it.

 

How to use M code provided in a blank query:
1) In Power Query, select New Source, then Blank Query
2) On the Home ribbon, select "Advanced Editor" button
3) Remove everything you see, then paste the M code I've given you in that box.
4) Press Done
5) See this article if you need help using this M code in your model.

 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.