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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

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)

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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)

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.