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
FrankWoody
Helper I
Helper I

M Language Extract Text

I would like to create some criteria when extracting the text based on the number of "-" and the text of the column starting with "ABLE TO PLAY".
If the column starts with the text "ABLE TO PLAY" and the amount of ; "-" is greater than 1 so I want it to extract the text following this RULE:
Text.BetweenDelimiters([SPENDING LOCATION], "-", "-", 0, 1)
But if the number of "-" is less than or equal to 1 then I want it to use:
Text.AfterDelimiter([SPENDING LOCATION], " ", 2).
If the column starts with any text other than "ABLE TO PLAY" it can return the normal value of the column without change.

1 ACCEPTED SOLUTION
FrankWoody
Helper I
Helper I

= Table.AddColumn(#"Renamed Columns", "Custom",
each if
   Text.Length(Text.Select([_5],"-"))>1 and Text.StartsWith([_5],"ABLE TO PLAY")
then Text.BetweenDelimiters([_5], "-", "-", 0, 1)
else if
  Text.Length(Text.Select([_5],"-"))<=1 and Text.StartsWith([_5], "ABLE TO PLAY")
then Text.AfterDelimiter([_5], " ", 2) else [_5])

Achieve after testing a lot! If anyone has the same problem or something similar I hope it helps.

View solution in original post

2 REPLIES 2
FrankWoody
Helper I
Helper I

= Table.AddColumn(#"Renamed Columns", "Custom",
each if
   Text.Length(Text.Select([_5],"-"))>1 and Text.StartsWith([_5],"ABLE TO PLAY")
then Text.BetweenDelimiters([_5], "-", "-", 0, 1)
else if
  Text.Length(Text.Select([_5],"-"))<=1 and Text.StartsWith([_5], "ABLE TO PLAY")
then Text.AfterDelimiter([_5], " ", 2) else [_5])

Achieve after testing a lot! If anyone has the same problem or something similar I hope it helps.

Hariharan_R
Solution Sage
Solution Sage

Hi,

Will you able to share some sample records?

Thanks

Hari

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