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
sscanlon
Helper II
Helper II

Extract Text After Delimeter but not the ACTUAL Delimeter?

I cannot find an answer anywhere to this so not sure it's even supported, but seems like such an easy thing to achieve. 

 

I have a string it looks like this 

 

Some random text I want to remove [Pr. Svc.] The text I want 

 

I want to keep the [text] This text here that is in red above

 

{{"Prod_Name", each Text.AfterDelimiter(_, " [", {0, RelativePosition.FromEnd}), type text}})

 

That is what I am using, and works fine but ends up like this, (and I try a 1 instead of 0 and other options and cannot figure it out)

Pr. Svc.] The text I want 

 

I want the [  at the beginning

 

Any thoughts would be much appreciated! 

 

Shawn

 

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

Hi @sscanlon ,

 

Please try to combine the "[" symbol with the split column.

 

= "[" & [Prod_Name.2]

vkkfmsft_0-1648696327552.png

 

Or just add a custom column:

 

= try Text.Range([Prod_Name], Text.PositionOf([Prod_Name],"[")) otherwise null

vkkfmsft_1-1648696369279.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
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

13 REPLIES 13
v-kkf-msft
Community Support
Community Support

Hi @sscanlon ,

 

Please try to combine the "[" symbol with the split column.

 

= "[" & [Prod_Name.2]

vkkfmsft_0-1648696327552.png

 

Or just add a custom column:

 

= try Text.Range([Prod_Name], Text.PositionOf([Prod_Name],"[")) otherwise null

vkkfmsft_1-1648696369279.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Your custom column worked perfect, was easier to do that single step and returned exactly what I needed, thank you very much! 

bchager6
Super User
Super User

Yes, zero zero A zero. Here's all my code:

let
Source = Excel.Workbook(File.Contents("C:\Users\xxxx\OneDrive - xxxx\Desktop\Book1.xlsx"), null, true),
Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],
#"Changed Type" = Table.TransformColumnTypes(Sheet1_Sheet,{{"Column1", type text}}),
#"Promoted Headers" = Table.PromoteHeaders(#"Changed Type", [PromoteAllScalars=true]),
#"Split Column by Delimiter" = Table.SplitColumn(#"Promoted Headers", "Column 1", Splitter.SplitTextByDelimiter("#(00A0)", QuoteStyle.Csv), {"Column 1.1", "Column 1.2"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Column 1.1", type text}, {"Column 1.2", type text}})
in
#"Changed Type1"

Unfortunately still not working, thank you for trying though I really appreciate it. 

 

Must be something wrong with my column or maybe my merge method earlier. Will play with it later and try to reply back.

bchager6
Super User
Super User

Do you want to just keep [Pr. Svc.] or [Pr. Svc.] The text I want?

 

If just the [Pr. Svc.], that's pretty straightforward:

 

Try using the Column from Examples function. 

  • Highlight the column you want to transform
  • From the Add Column ribbon, select the Column from Examples drop-down
  • Select, "From Selection"
  • A new, blank column will appear
  • Type [Pr. Svc.]
  • Click OK

Hi thank you for the help 

I need to keep [Pr. Svc.] The text I want 

 

Issue is - it is these 3 at start

[Pr. Svc] 

[Sh. Svc]

[Comm.]

 

The a space followed by random text (different for each one of the above). 

 

So not sure examples function would work? 

Try inserting this in to your advanced editor:

 

#"Inserted Text After Delimiter" = Table.AddColumn(#"Your previous step name", "Text After Delimiter", each Text.AfterDelimiter([Your column name], " "), type text)

Hi, that worked and grabs the text after [xxxxx] but is just that text 

 

It is strange that text before or after delimeter removes the actual delimeter, is this normal? 

 

I am saying that I want to extract AFTER the delimeter, not including it? 

Split Column by Delimiter worked for me too:

bchager6_1-1648499918534.pngbchager6_2-1648499948520.png

 



Do you want your results to look like what I have in the Text After Delimiter column? I'm confused because earlier you wrote that you want to keep "[Pr. Svc.] The text I want" and now you're saying you want to extract after the delimiter, not including it. What delimiter?

bchager6_1-1648497906678.png

 



sorry for confusion, I want exactly what you show there, but it will make more sense with my image here. I don't get what you do, I must be setting something wrong? 

 

2022-03-28_13-58-12.png

If your settings match mine, I think it's going to work:

bchager6_0-1648501511403.png

 

I tried but just shows null for 2nd column

 

Is that a zero zero A zero? I am not familiar with Hex? for characters.

 

Thanks again for all the help

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.