Find and append a value to a field

I'm trying to align some inconsistencies with our data. What I'd like to do is find any value that does not end with a '/' and append it with that character.

  1. Is there a case statement where we can look for a field that does or does not end in a character?
  2. I assume if I can do that, I can just append those without with the '/'

Best Answer

  • KristinDavis
    KristinDavis Member
    Answer ✓

    Thank you both! This was really helpful. I ended up using a modification:

    CASE
    WHEN RIGHT(Page Path,1) = '/' THEN Page Path
    ELSE CONCAT(Page Path,'/')
    END

Answers

  • MarkSnodgrass
    edited April 9

    You could do this:

    CASE WHEN RIGHT(myfield,1) = '/' THEN myfield ELSE CONCAT(myfield,'/') END
    

    **Check out my Domo Tips & Tricks Videos

    **Make sure to <3 any users posts that helped you.
    **Please mark as accepted the ones who solved your issue.
  • Here's a regex version:

    REGEXP_REPLACE(`field`, '^(.+)\/?', '$1/')

    **Was this post helpful? Click Agree or Like below**
    **Did this solve your problem? Accept it as a solution!**
  • KristinDavis
    KristinDavis Member
    Answer ✓

    Thank you both! This was really helpful. I ended up using a modification:

    CASE
    WHEN RIGHT(Page Path,1) = '/' THEN Page Path
    ELSE CONCAT(Page Path,'/')
    END