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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Anonymous
Not applicable

Extracting Text in Power Query

I have following table column:

shwetadalal_0-1639738454965.png

 

I want to get a new column with text after delimiter for each line in each row if delimiter "-" exists else null.. Eg in the 1st row I should get Timesheet Report and Review.

 

I wrote the following query but it is giving me only 'Timesheet Report' but not Review

if [Project]="Free Time" and Text.Contains([#"Work Description"], "-") then Text.BetweenDelimiters([#"Work Description"],"-","#(lf)") else nulll

 

Any help is appreciated

Thanks in Advance

9 REPLIES 9
Fowmy
Super User
Super User

@Anonymous 

You need to first split your records into rows, using Line Feed 

Fowmy_0-1639750543400.png

Then, under Add Column tab, Extract and choose Text After Delimiter as follows

Fowmy_1-1639750616802.png


Create a blank Query, go to the Advanced Editor, clear the existing code, and paste the codes give below and follow the steps.

Fowmy_2-1639750641247.png

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("RY3BCsIwEAV/ZcnZBNQ/kIIXD1Lrqeaw2Eez0Cal2Rr8e0suHgdmmL43R0c38BoljmQ7mZEDoNRiSavSK54cXaY02hYfQTH+UJOGv3SfONasStdNhh1sB56pkfzecpYUqYgGeoQC5V08O/o/nsvACuP9Dw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"c Work Description" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"c Work Description", type text}}),
    #"Split Column by Delimiter" = Table.ExpandListColumn(Table.TransformColumns(#"Changed Type", {{"c Work Description", Splitter.SplitTextByDelimiter("#(lf)", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "c Work Description"),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"c Work Description", type text}}),
    #"Inserted Text Before Delimiter" = Table.AddColumn(#"Changed Type1", "Text Before Delimiter", each Text.AfterDelimiter([c Work Description], "-"), type text)
in
    #"Inserted Text Before Delimiter"

 

 

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Anonymous
Not applicable

Hi @Fowmy 

Is it possible to extract without splitting into rows because I want the content of that particular row together since each work description belongs to a member?

@Anonymous 

When you split into rows, all other columns including the member column will be repeated for each row. You group them as you need. This is a good approach. Check this code:

Fowmy_0-1639813608535.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Rc1BCsIwFATQq3yybgPqCSwFNwrS1lXNItqh+dAkJUkN3t5SF10OzJvpe3GDxQuBzqIQB0lX6ODYjVR2bBENkKjB7EOipztKqiY/lg0+jCxUsfPqz2v9pfuk3TaxgcvCwxrKDtpSzfG9xMjeUeZkqDUZSa/Fk6T97zEPOkEo9QM=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Memeber = _t, #"c Work Description" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"c Work Description", type text}}),
    #"Split Column by Delimiter" = Table.ExpandListColumn(Table.TransformColumns(#"Changed Type", {{"c Work Description", Splitter.SplitTextByDelimiter("#(lf)", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "c Work Description"),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"c Work Description", type text}}),
    #"Inserted Text Before Delimiter" = Table.AddColumn(#"Changed Type1", "Text Before Delimiter", each Text.AfterDelimiter([c Work Description], "-"), type text)
in
    #"Inserted Text Before Delimiter"


How do you want the new column ?. You show in different rows to concatenate them

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Anonymous
Not applicable

@Fowmy 

I dont want multiple records for the same member 

In my desired output the row with Member A should have Timesheet Report, Review against it in a single row

@Anonymous 

You try this :

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("Rc1BCsIwFATQq3yybgPqCSwFNwrS1lXNItqh+dAkJUkN3t5SF10OzJvpe3GDxQuBzqIQB0lX6ODYjVR2bBENkKjB7EOipztKqiY/lg0+jCxUsfPqz2v9pfuk3TaxgcvCwxrKDtpSzfG9xMjeUeZkqDUZSa/Fk6T97zEPOkEo9QM=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Memeber = _t, #"c Work Description" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"c Work Description", type text}}),
    #"Split Column by Delimiter" = Table.ExpandListColumn(Table.TransformColumns(#"Changed Type", {{"c Work Description", Splitter.SplitTextByDelimiter("#(lf)", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "c Work Description"),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"c Work Description", type text}}),
    #"Inserted Text Before Delimiter" = Table.AddColumn(#"Changed Type1", "Text Before Delimiter", each Text.AfterDelimiter([c Work Description], "-"), type text),
    #"Grouped Rows" = Table.Group(#"Inserted Text Before Delimiter", {"Memeber"}, {{"Result", each Text.Combine([Text Before Delimiter]," "), type text}})
in
    #"Grouped Rows"

Fowmy_0-1639814122177.png

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Anonymous
Not applicable

@Fowmy I have a date and Free Time column too in this table as shown in the image. So if I group by Team Member for each day using Table.Group function then it will return a table. I tried your solution but didn't work in my case

shwetadalal_0-1639830499511.png

 

Hi @Anonymous 

 

You just need to modify the last step of @Fowmy 's solution. You can group by Team member, Date and Project columns at the same time. Do you want below result?

22010401.jpg

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("jY6xDoIwGIRf5U9nSqQOzhKiCyYGcUKGKhf4EyikLRLf3oqDq9t3ucuXqyqhNiqRiZJqJyJxsACVPCDwCQPusLQPnMSUQ1vDpiX56V0HeCowjdbTzaiY0n5sZYEnYxF19Ic3/Xoz/aJzr83qXk3HmZsQZAk9UMbuMTvHo6GFfUeXboHXYbiN6XfkOjXaQ9T1Gw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Project = _t, Memeber = _t, #"c Work Description" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"c Work Description", type text}}),
    #"Split Column by Delimiter" = Table.ExpandListColumn(Table.TransformColumns(#"Changed Type", {{"c Work Description", Splitter.SplitTextByDelimiter("#(lf)", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "c Work Description"),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"c Work Description", type text}}),
    #"Inserted Text Before Delimiter" = Table.AddColumn(#"Changed Type1", "Text Before Delimiter", each Text.AfterDelimiter([c Work Description], "-"), type text),
    #"Grouped Rows" = Table.Group(#"Inserted Text Before Delimiter", {"Memeber","Date","Project"}, {{"Result", each Text.Combine([Text Before Delimiter],"#(lf)"), type text}})
in
    #"Grouped Rows"

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

mahoneypat
Microsoft Employee
Microsoft Employee

Please try this instead.

 

Text.AfterDelimiter([Work Description], "- ")

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

@mahoneypat 

I tried that too but it only extracts text for single line. Eg. From 1st row Timesheet Report and Review should be extracted but Text.AfterDelimiter([Work Description], "- ") extracts 'Timesheet Report Blog-Review' since it considers Blog-Review is also after the first delimeter '-'

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors