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

Split string with delimiters in two columns and align them based on their sequence

hi Experts, 

my data is like this: 

IDNameEmail
1234['Johny Washer', 'Polly Dryer', 'Molly Windows']['JohnyW@abc.com', 'DryerP@xyz.com', 'MollyW@yahoo.com']
6453['Mickey Mouse']['MouseM@Disney.com']
5678['Star Trekky', 'War Starry']['Trek@gmail.com', 'Starry@junk.com']

 

Expected outcome is: 

 

IDNameEmail
1234Johny WasherJohnyW@abc.com
1234Polly DryerDryerP@xyz.com
1234Molly WindowsMollyW@yahoo.com
6453Mickey MouseMouseM@Disney.com
5678Star TrekkyTrek@gmail.com
5678War StarryStarry@junk.com

 

If I use split column using comma delimiter on each of the Name and Email columns, it splits correctly in to rows but it creates redundant rows for all combination. For example, Johny Washer gets aligned with JohnyW@abc.com as well as DryperP@xyz.com and MollyW@yahoo.com in 3 distinct rows. What I need is a split by delimiter and then aligning the first entry in Name column with the first entry in Email column and so on. The ID column should get repeated like shown in the expected outcome. 

 

I also need to do this each time I refresh data. So a manual right clicking for split column won't work. Is there any way to write a DAX for this so that the solution is automated and scalable? 

 

Thank you! 

4 REPLIES 4
Anonymous
Not applicable

Thank you.. Will test this out but what is the long text string in that code (binary.fromtext ?)

Appreciate help! 

 

Hi @Anonymous 

That long string is how data from "Enter Data" is kept.  Just ignore it.



Proud to be a Super User!

daxformatter.com makes life EASIER!
Anonymous
Not applicable

I couldn't figure out what that long test was and not sure what to replace it with or what a clean code would look like. I have not used "let" logic before. @amitchandak if you could attach the workbook, that would be awesome.

 

Just as an intermin solution, here's what I did. 

First split the concatenated strings using comma as the delimited and used substitute to remove [ and quotes. Used Pathitem(Substitute function and had 8 distinct columns for names and emails each. Concatenated them again to have 1:1 match with name and email. Hence, got 8 distinct columns for Name-Email1, Name-Email2 etc. 

Then created a new table and used UNION(SUMMARIZE to have ID in the first column and Name-Email in the second column. Then split the Name and Email into 2 distinct columns. I tested with changing values in the underlying CSV file and it works well. The problem is that it creates blank rows in between.. maybe I can setup a filter to remove the blanks. 

 

However, I would still prefer to use @amitchandak 's method since it will get rid of multiple steps. Thanks! 

amitchandak
Super User
Super User

@Anonymous , Try this code in a blank query in Power Query (Transform Data)

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("ZY+9CsIwFEZfJWQuUu2fY4ZOQqCgkCFmiDXYmDaBxKLXp9e2Q2k7Bb5z7/luOMf7Q5LiCPNrH8eH4uQaC4jJ0Cg/JRGa3sq1LaDSwxrQETBt7+4dpkishIzIW72rXbfcHGUV+cB3y0YrIyAb52YqsIg4ztMsmRuoro0CRF0f1KZ+TCkpdbAK1p4sL47z6PklPbp4ZQwsT2H/fIAeNvphnDw6qdvtD6YV8uytWRSLHw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, Name = _t, Email = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}, {"Name", type text}, {"Email", type text}}),
    #"Replaced Value" = Table.ReplaceValue(#"Changed Type","[","",Replacer.ReplaceText,{"Name", "Email"}),
    #"Replaced Value1" = Table.ReplaceValue(#"Replaced Value","]","",Replacer.ReplaceText,{"Name", "Email"}),
    #"Added Custom" = Table.AddColumn(#"Replaced Value1", "Custom", each List.Zip({Text.Split([Name], ","), Text.Split([Email], ",")})),
    #"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "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.SplitTextByDelimiter(",", QuoteStyle.Csv), {"Custom.1", "Custom.2"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Custom.1", type text}, {"Custom.2", type text}}),
    #"Removed Columns" = Table.RemoveColumns(#"Changed Type1",{"Name", "Email"})
in
    #"Removed Columns"



amitchandak_0-1701316943652.png

 

 

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.