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

New Table to Create Categorize Existing Columns

Hello sirs.. I might not have described title clearly.. what I want to do is converting following data;

 

DateUnit1 Unit2Unit3
01.01.2020100200300
02.01.2020150300250

 

into -->

 

DateUnitValue
01.01.20201100
02.01.20201150
01.01.20202200
02.01.20202300
01.01.20203300
02.01.20203250

 

How can I do it ? 

 

Thanks

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , Unpivot and then either split or replace Unit with empty string

https://radacad.com/pivot-and-unpivot-with-power-bi
Transpose : https://yodalearning.com/tutorials/power-query-helps-transposing-data/

https://docs.microsoft.com/en-us/powerquery-m/text-replace

Or right click on the new column and use replace unit with empty

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

2 REPLIES 2
PhilipTreacy
Super User
Super User

Hi @Anonymous 

Use this code or this PBIX file

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjDUAyIjAyMDJR0lQwMQaQQmjYFkrA5QgRGyAlOYFFAZkB0bCwA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, #"Unit1 " = _t, Unit2 = _t, Unit3 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Unit1 ", Int64.Type}, {"Unit2", Int64.Type}, {"Unit3", Int64.Type}}),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Date"}, "Attribute", "Value"),
    #"Extracted Text After Delimiter" = Table.TransformColumns(#"Unpivoted Other Columns", {{"Attribute", each Text.AfterDelimiter(_, "Unit"), type text}}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Extracted Text After Delimiter",{{"Attribute", Int64.Type}}),
    #"Sorted Rows" = Table.Sort(#"Changed Type1",{{"Attribute", Order.Ascending}, {"Date", Order.Ascending}})
in
    #"Sorted Rows"

 

converted-table.png

Regards

Phil


If I answered your question please mark my post as the solution.
If my answer helped solve your problem, give it a kudos by clicking on the Thumbs Up.



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


amitchandak
Super User
Super User

@Anonymous , Unpivot and then either split or replace Unit with empty string

https://radacad.com/pivot-and-unpivot-with-power-bi
Transpose : https://yodalearning.com/tutorials/power-query-helps-transposing-data/

https://docs.microsoft.com/en-us/powerquery-m/text-replace

Or right click on the new column and use replace unit with empty

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

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.