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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

unpivot table with milestones

Hello everybody,

 

I need help with the following example.

 

I want the milestones start date --> (1.RH, 2. LH, 3.Best, 4.VA, 5.BÜ, 6.EA) and end date --> (1.RH, 2. LH, 3.Best, 4.VA, 5.BÜ, 6.EA) unpivotieren like example after.

 

 

example before

example beforeexample before

 

example after

example afterexample after

 

 

@JWE 

 

 

 

 

 

1 ACCEPTED SOLUTION
ImkeF
Community Champion
Community Champion

Hi @Anonymous 

yes, make sure your headers contain characters that make splitting like in the following example possible:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8nQxVNJRAmEjIDYGYhOlWB2QOIhvCsRmQGwOxBZKsbEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [ID = _t, A_1 = _t, A_2 = _t, B_1 = _t, B_2 = _t]),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"ID"}, "Attribute", "Value"),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Unpivoted Other Columns", "Attribute", Splitter.SplitTextByDelimiter("_", QuoteStyle.Csv), {"Attribute.1", "Attribute.2"}),
    #"Pivoted Column" = Table.Pivot(#"Split Column by Delimiter", List.Distinct(#"Split Column by Delimiter"[Attribute.1]), "Attribute.1", "Value")
in
    #"Pivoted Column"

 

attaching file as well

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

View solution in original post

7 REPLIES 7
amitchandak
Super User
Super User

If the first row is not there and the second row have unique column name, you can do it in Dax Like that

union(
SELECTCOLUMNS(table,table[Project Id], "Milestore" ,"RH1", "Start Date", table[1.RH.start], "END Date", table[1.RH.start]),
SELECTCOLUMNS(table,table[Project Id], "Milestore" ,"2LH", "Start Date", table[1.LH.start], "END Date", table[1.LH.start])
)

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

first row was for illustration.

is this possible via unpivot?

 

@Anonymous 

I have suggested dax way in first post. @ImkeF , suggsted a better way in M. Can you check solution work for you

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
ImkeF
Community Champion
Community Champion

Hi @Anonymous 

yes, make sure your headers contain characters that make splitting like in the following example possible:

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8nQxVNJRAmEjIDYGYhOlWB2QOIhvCsRmQGwOxBZKsbEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [ID = _t, A_1 = _t, A_2 = _t, B_1 = _t, B_2 = _t]),
    #"Unpivoted Other Columns" = Table.UnpivotOtherColumns(Source, {"ID"}, "Attribute", "Value"),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Unpivoted Other Columns", "Attribute", Splitter.SplitTextByDelimiter("_", QuoteStyle.Csv), {"Attribute.1", "Attribute.2"}),
    #"Pivoted Column" = Table.Pivot(#"Split Column by Delimiter", List.Distinct(#"Split Column by Delimiter"[Attribute.1]), "Attribute.1", "Value")
in
    #"Pivoted Column"

 

attaching file as well

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Anonymous
Not applicable

it works, thanks a lot.

I need the data for a Gantt Chart - now i have my attributes and my start and end date.

 

Is it possible to show shifts in a different color?

 

like this example:

Unbenannt.PNG

 
ImkeF
Community Champion
Community Champion

Hi @Anonymous 

please open another thread for this, as this is a completely other topic and should have different title/tags.

 

In there, please make sure to clarify if you're actually looking for an Excel-solution or a Power BI. 

You should also clarify where to find the criteria that makes the distinction between the 2 statuses.

 

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

But @ImkeF  can tell us a better solution.

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.