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

Help with DAX to Trim

Hello,

 

I am trying to trim 4 characters off the back of a field. For instance, the field might contain "HOUSTON, TX (42H)" and I would like to have a custom column which will contain only "HOUSTON, TX". Here is the DAX I am trying to use, but am getting an error regarding Type Text to Type Number:

 

Trimmed Work Loc = left('All Current Employees'[Work Location],LEN('All Current Employees'[Work Location]-5))

 

Any ideas? Thanks.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Your parens just aren't lined up right.

Trimmed Work Loc = left('All Current Employees'[Work Location],LEN('All Current Employees'[Work Location])-5)

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Your parens just aren't lined up right.

Trimmed Work Loc = left('All Current Employees'[Work Location],LEN('All Current Employees'[Work Location])-5)

Thanks, @Anonymous. Now I get an error stating, "An argument of function 'LEFT' has the wrong data type or has an invalid value".

 

There will be times that there are blanks, I don't know if that's the issue here?

Got it, just used this:

 

Trimmed Work Loc = if('All Current Employees'[Work Location] ="", "",left('All Current Employees'[Work Location],LEN('All Current Employees'[Work Location])-5))

 

thanks, @Anonymous!

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.