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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
EllieSim
Helper II
Helper II

Merge values from multiple rows into one with a separator for each unique list item

Hello,

 

I have a table which lists items (column Code/Descriptor) multiple times depending on the number of corresponding applicable options (column Applicable Schedules). The column Code/Descriptor contains duplicate values, the values in Available Schedules are unique per Code/Descriptor but not unique within the entire column.

 

Capture.PNG

 

Instead, I am trying to achieve the following result:

 

Code/DescriptorCodeCode LevelAvailable Schedules
5.10.1.3.4 Gantries, Trolleys, Blocks and the like5.10.1.3.4Level 573-04; 84-59; 84-08; 84-13; 84-55; 73-03; 82-07; 84-07; 73-02
5.10.1.3.5 Controls and Electrical Work5.10.1.3.5Level 544-10
5.10.1.6.2 Complete Hoists Installation5.10.1.6.2Level 584-11; 84-59

 

Is there a way to achieve this either in the query editor or with a DAX expression/calculated column, ideally without using the M language?

 

Many thanks for your help.

 

Ellie

1 ACCEPTED SOLUTION
v-stephen-msft
Community Support
Community Support

Hi @EllieSim ,

 

You can group on Code/Descriptor, Code and Code Level, choose some dummy operation for Available Schedules(e.g. Max, not "All Rows") and then adjust the generated code to combine the names:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("tdKxCsIwEAbgVzk6tyFpG1tXRVRwFBxKh1APLD0baYLg23vFwXZxsdkukHwJ/5+qirRQUiiRiRz2pvdDiy6G82CJ8MXThmzTOTD9FfwNgdoOo3hyiBcnfCKB5qnIEplHdbysWuaJXodQZRlCVVmQBPTi6thWgFzTRBZB2lpeHRNI56qGrWXV0sfYETZ8R2MILnboppSeUTkXL6fUSqRM3R+EHuFgW+cdHHvnDZHxre2/FO/83fZflFLLvYp/S/0G", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Code/Descriptor" = _t, Code = _t, #"Code Level" = _t, #"Available Schedules" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Code/Descriptor", type text}, {"Code", type text}, {"Code Level", type text}, {"Available Schedules", type text}}),
    #"Grouped Rows" = Table.Group( #"Changed Type" , {"Code/Descriptor","Code","Code Level"}, {{"Available", each Text.Combine([Available Schedules], ";"), type text}})
in
    #"Grouped Rows"

2.png

 

You can check more details from here.

 

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-stephen-msft
Community Support
Community Support

Hi @EllieSim ,

 

You can group on Code/Descriptor, Code and Code Level, choose some dummy operation for Available Schedules(e.g. Max, not "All Rows") and then adjust the generated code to combine the names:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("tdKxCsIwEAbgVzk6tyFpG1tXRVRwFBxKh1APLD0baYLg23vFwXZxsdkukHwJ/5+qirRQUiiRiRz2pvdDiy6G82CJ8MXThmzTOTD9FfwNgdoOo3hyiBcnfCKB5qnIEplHdbysWuaJXodQZRlCVVmQBPTi6thWgFzTRBZB2lpeHRNI56qGrWXV0sfYETZ8R2MILnboppSeUTkXL6fUSqRM3R+EHuFgW+cdHHvnDZHxre2/FO/83fZflFLLvYp/S/0G", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Code/Descriptor" = _t, Code = _t, #"Code Level" = _t, #"Available Schedules" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Code/Descriptor", type text}, {"Code", type text}, {"Code Level", type text}, {"Available Schedules", type text}}),
    #"Grouped Rows" = Table.Group( #"Changed Type" , {"Code/Descriptor","Code","Code Level"}, {{"Available", each Text.Combine([Available Schedules], ";"), type text}})
in
    #"Grouped Rows"

2.png

 

You can check more details from here.

 

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you very much.

Anonymous
Not applicable

Hi, thanks for your swift reply. Any thoughts on how to fix the semicolons when merging the pivoted columns? Find and replace still leaves a semicolon at the front and end of each merged result.

Capture.PNG

 

 

 

 

 

 

 

 

 

 

 

 

Capture.PNG

 

 

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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