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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Tomhayw
Helper I
Helper I

Split column by delimiter with a character immediately after it

Hi there,

 

I have this (dummy) string of text that I am trying to split into columns:

 

This,piece, of,text,needs,to,be,split

 

The delimiter I want to split by has a character immediately before and after it.

Thispiece, oftextneedstobesplit

 The one that I don't want to split as a delimiter has a space immediately after it.

 

How do I go about this?

 

Thanks,

Tom

1 ACCEPTED SOLUTION
watkinnc
Super User
Super User

You can use Replace values, and replace ", " with just " " or something that sticks out like "*', and then split by the comma ",".

 

--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!!

View solution in original post

3 REPLIES 3
AlexisOlson
Super User
Super User

A fancier way to do this would be to use a character transition splitter. This will keep the commas though, so you'd probably want to trim those off.

 

Full sample query you can paste into the Advanced Editor of a new blank query:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCsnILNYpyExNTtVRyE/TKUmtKNHJS01NKdYpyddJStUpLsjJLFGKjQUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Text = _t]), 
  #"Split Column by Character Transition" = Table.SplitColumn(
    Source, 
    "Text", 
    Splitter.SplitTextByCharacterTransition({","}, each _ <> " ")
  ), 
  #"Trimmed Text" = Table.TransformColumns(
    #"Split Column by Character Transition", 
    {}, 
    each Text.TrimEnd(_, ",")
  )
in
  #"Trimmed Text"

 

 

watkinnc
Super User
Super User

You can use Replace values, and replace ", " with just " " or something that sticks out like "*', and then split by the comma ",".

 

--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!!

Thank you,

 

I was too busy trying to overcomplicate it I forgot about the easy way around!

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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