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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
apeeltyler
Frequent Visitor

I'm using Text.Contains and need to remove a single text value and add another value in its place.

Below is the formula I'm using

 

if Text.Contains([Employee ID], "T") then "0" else [Employee ID]

 

What I'm after is if the Employee ID contains a 'T', for example: T0123, I want to remove the 'T' and add a '0' (zero) in place of the 'T'.

 

How do I accomplish this?

1 ACCEPTED SOLUTION
Syk
Super User
Super User

If your ID's are a specific length, you can use text.end 
try

if Text.Contains([Employee ID], "T") then "0" & text.right(Employee ID,4) else [Employee ID]

View solution in original post

6 REPLIES 6
Syk
Super User
Super User

If your ID's are a specific length, you can use text.end 
try

if Text.Contains([Employee ID], "T") then "0" & text.right(Employee ID,4) else [Employee ID]

Thanks!  However, I'm getting this error:

Expression.Error: The name 'Text.Right' wasn't recognized. Make sure it's spelled correctly.

 

edit to add:

If it helps, I'm in Power Query Editor creating a new column 

= Table.AddColumn(#"Removed Columns2", "EE ID", each if Text.Contains([Employee ID], "T") then "0" & Text.Right([Employee ID],4) else [Employee ID])

 

My bad! It's text.end 🙂

It's funny because that "worked", no Syntax Errors were detected, but all results came back as Error.  Employee ID is a Whole Number column

Hmm.. It shouldn't automatically set it to whole number if some of them start with 'T'... Try to add a change type right before you add this column. Set it to a text type instead.

Your formula worked!  What's odd is that the folks that have 'T' in the ID pulled in as Error.  There were only 3, so I'm just removing them, as they were going to be filtered out.  

I'm definately keeping your formula around for future use. Thanks!!🍻

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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.