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
lidderdj
Frequent Visitor

Matching delimited values in one column with delimited values in another column

Hi, 

 

I have data in the following format:

NameFile Location
Test 1a;b;c1;2;3
Test 2d4
Test 3e;f5;6

 

I'd like to expand the rows, so that each row contains a Name, File, Location match. For example:

NameFileLocation
Test 1a1
Test 1b2
Test 1c3
Test 2d4
Test 3e5
Test 3f6

 

It would be even better if this was possible:

NameFileLocation
Test 1.1a1
Test 1.2b2
Test 1.3c3
Test 2d4
Test 3.1e5
Test 3.2f6

 

Does anyone know how this can be done? Thank you all very much for your time. 

 

- Daniel

1 ACCEPTED SOLUTION
Stachu
Community Champion
Community Champion

I'd do it in the query editor, see example below (create a new query and paste the code from below in the Advanced Editor), you can examine the steps in the transformation in the Query Settings pane on the right of the Query Editor

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCkktLlEwVNJRSrROsk4G0obWRtbGSrE6UCkjoFAKEJsghIyB3FTrNCBpam2mFBsLAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Name = _t, #"File " = _t, Location = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Name", type text}, {"File ", type text}, {"Location", type text}}),
    FileToList = Table.TransformColumns(#"Changed Type",{{"File ", each Text.SplitAny(_, ";")}}),
    LocationToList = Table.TransformColumns(FileToList,{{"Location", each Text.SplitAny(_, ";")}}),
    ZipFileAndLocation = Table.AddColumn(LocationToList, "Custom", each List.Zip({[#"File "],[Location]})),
    #"Removed Columns" = Table.RemoveColumns(ZipFileAndLocation,{"File ", "Location"}),
    #"Expanded Custom" = Table.ExpandListColumn(#"Removed Columns", "Custom"),
    #"Extracted Values" = Table.TransformColumns(#"Expanded Custom", {"Custom", each Text.Combine(List.Transform(_, Text.From), ";"), type text}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Extracted Values", "Custom", Splitter.SplitTextByEachDelimiter({";"}, QuoteStyle.Csv, false), {"File", "Location"})
in
    #"Split Column by Delimiter"


Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

View solution in original post

2 REPLIES 2
Stachu
Community Champion
Community Champion

I'd do it in the query editor, see example below (create a new query and paste the code from below in the Advanced Editor), you can examine the steps in the transformation in the Query Settings pane on the right of the Query Editor

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCkktLlEwVNJRSrROsk4G0obWRtbGSrE6UCkjoFAKEJsghIyB3FTrNCBpam2mFBsLAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Name = _t, #"File " = _t, Location = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Name", type text}, {"File ", type text}, {"Location", type text}}),
    FileToList = Table.TransformColumns(#"Changed Type",{{"File ", each Text.SplitAny(_, ";")}}),
    LocationToList = Table.TransformColumns(FileToList,{{"Location", each Text.SplitAny(_, ";")}}),
    ZipFileAndLocation = Table.AddColumn(LocationToList, "Custom", each List.Zip({[#"File "],[Location]})),
    #"Removed Columns" = Table.RemoveColumns(ZipFileAndLocation,{"File ", "Location"}),
    #"Expanded Custom" = Table.ExpandListColumn(#"Removed Columns", "Custom"),
    #"Extracted Values" = Table.TransformColumns(#"Expanded Custom", {"Custom", each Text.Combine(List.Transform(_, Text.From), ";"), type text}),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Extracted Values", "Custom", Splitter.SplitTextByEachDelimiter({";"}, QuoteStyle.Csv, false), {"File", "Location"})
in
    #"Split Column by Delimiter"


Did I answer your question? Mark my post as a solution!
Thank you for the kudos 🙂

That's brilliant. Thank you so much! 

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.