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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
jcastr02
Post Prodigy
Post Prodigy

Unpivoting into different columns

I am trying to group a column into one value that have the same work order, see example below.  Work order 29999 all seperate line items, but want to group the work order tag reason into one cell.  Trying to manipulate this in power query...

Current

Work Order NumberWork Order Tag ReasonReigonSite
12340 Reigon 6Store
25789 Reigon 6Store
29999FIX SLA 1Reigon 9DC
29999FIX SLA 2Reigon 9DC
29999FIX SLA 3Reigon 10DC

Expected Result 

Work Order NumberWork Order Tag ReasonReigonSite
12340 Reigon 6Store
25789 Reigon 6Store
29999FIX SLA 1, FIX SLA 2, FIX SLA 3Reigon 9DC
1 ACCEPTED SOLUTION
BA_Pete
Super User
Super User

Hi @jcastr02 ,

 

Here you go:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQyNjFQ0lFSAOKg1Mz0/DwFMyAzuCS/KFUpVidaycjU3MISrwJLIACKuHlGKAT7OCoYIhSChF2csaoyIkqVMaaqWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Work Order Number" = _t, #"Work Order Tag Reason" = _t, Reigon = _t, Site = _t]),
    chgAllTypes = Table.TransformColumnTypes(Source,{{"Work Order Number", type text}, {"Work Order Tag Reason", type text}, {"Reigon", type text}, {"Site", type text}}),
    groupRowsList = Table.Group(chgAllTypes, {"Work Order Number", "Reigon", "Site"}, {{"Work Order Tag Reason", each Text.Combine([Work Order Tag Reason], ", "), type nullable text}})
in
    groupRowsList

 

It's a basic Power Query group function, but you switch out one of the standard operators from the GUI to the Text.Combine function instead.

 

Gives me this:

BA_Pete_0-1612879733732.png

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

3 REPLIES 3
BA_Pete
Super User
Super User

Hi @jcastr02 ,

 

Here you go:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQyNjFQ0lFSAOKg1Mz0/DwFMyAzuCS/KFUpVidaycjU3MISrwJLIACKuHlGKAT7OCoYIhSChF2csaoyIkqVMaaqWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Work Order Number" = _t, #"Work Order Tag Reason" = _t, Reigon = _t, Site = _t]),
    chgAllTypes = Table.TransformColumnTypes(Source,{{"Work Order Number", type text}, {"Work Order Tag Reason", type text}, {"Reigon", type text}, {"Site", type text}}),
    groupRowsList = Table.Group(chgAllTypes, {"Work Order Number", "Reigon", "Site"}, {{"Work Order Tag Reason", each Text.Combine([Work Order Tag Reason], ", "), type nullable text}})
in
    groupRowsList

 

It's a basic Power Query group function, but you switch out one of the standard operators from the GUI to the Text.Combine function instead.

 

Gives me this:

BA_Pete_0-1612879733732.png

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Hi @jcastr02 ,

 

Did this work ok for you? I saw that you kudoed but didn't mark as the solution.

If this isn't working for you then let me know what's wrong and I'll have another look.

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




amitchandak
Super User
Super User

@jcastr02 , You can create a measure and use that in visual

 

concatenatex(Table, Table[Work Order Tag])

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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