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
Anonymous
Not applicable

split columns with with multiple spaces between fields

Hey Team,

 

We need to split text which looks like this to columns:

 

Name= John Doe Date=2021-2-3 Address= New York

Name= Sam Doe Date=2021-2-3 Address= City= Paris

 

Is there a way to parse this to different columns?

 

Some fields are blank from the log files.

 

 

10 REPLIES 10
v-stephen-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please check the attachment.

The workaround is to Split columns by delimiter.

 

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.

watkinnc
Super User
Super User

it was actually trickier than it seemed! Here you are.

 

Spilt those fields! 


--Nate


I’m usually answering from my phone, which means the results are visualized only in my mind. You’ll need to use my answer to know that it works—but it will work!!
Anonymous
Not applicable

Im not able to download this @watkinnc 

Jakinta
Solution Sage
Solution Sage

This also can be done.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8kvMTbVV8MrPyFNwyU9VcEksSbU1MjAy1DXSNVZwTEkpSi0utlXwSy1XiMwvylaK1YFpCU7MxafDObOk0lYhILEos1gpNhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Split Column by Delimiter" = Table.SplitColumn(Source, "Column1", Splitter.SplitTextByAnyDelimiter({"Name= "," Date=", " Address= "}, QuoteStyle.Csv), {"Column1","Name", "Date", "City"}),
    #"Removed Columns" = Table.RemoveColumns(#"Split Column by Delimiter",{"Column1"}),
    #"Replaced Value" = Table.ReplaceValue(#"Removed Columns","City= ","",Replacer.ReplaceText,{"City"})
in
    #"Replaced Value"
Anonymous
Not applicable

It has variable column names. 

watkinnc
Super User
Super User

I would split by delimiter "=", then Text.Trim the whole table to remove any leading or trailing spaces. I would then add an index column and move it all the way left. Then you should be able to use the Pivot function in the GUI to pivot the columns. 
--Nate


I’m usually answering from my phone, which means the results are visualized only in my mind. You’ll need to use my answer to know that it works—but it will work!!
Anonymous
Not applicable

Can you help me with a sample pbix file?

I'm on my phone on the road. Give me an hour or so  🙂

--Nate


I’m usually answering from my phone, which means the results are visualized only in my mind. You’ll need to use my answer to know that it works—but it will work!!
Anonymous
Not applicable

@watkinnc were you able to generate a sample pbix?

Anonymous
Not applicable

Thank you!

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.

Top Solution Authors
Top Kudoed Authors