Forum Discussion

apeeltyler's avatar
apeeltyler
Frequent Visitor
3 years ago
Solved

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?

  • 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]

6 Replies

  • Syk's avatar
    Syk
    Icon for Resident Rockstar rankResident Rockstar

    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]
    • apeeltyler's avatar
      apeeltyler
      Frequent Visitor

      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])

       

      • Syk's avatar
        Syk
        Icon for Resident Rockstar rankResident Rockstar

        My bad! It's text.end 🙂