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

trimming text strings in columns with multiple patterns

Hello!

 

I'd like to remove / trim any text after the hyphen in order to consolidate minor variations in batches.  As you can see in the graphic below, there are variations of the batch numbers and I'd like like to remove any text past the hyphen so that there are two batches: B10107 and B10108.  I'm bringing in this data from a SQL query, and could address this issue there.  However, I'm curious from a Power BI perspective how this could be solved.

formerlyknownas_1-1612261214105.png

 

 

 

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@formerlyknownas ,

Try a new column like

left([batch], search("-",[batch],,len([batch])+1) -1)

View solution in original post

2 REPLIES 2

Thanks, this worked perfectly. 

amitchandak
Super User
Super User

@formerlyknownas ,

Try a new column like

left([batch], search("-",[batch],,len([batch])+1) -1)

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.