LIKE or CONTAIN operator in calculation field to find part of a string

Answered

Comments

6 comments

  • Rainer Grabowski (FVM)

    With this you can get the last 4 characters of the string, than you can compare it in an IF-Condition:

    var a = @fieldName
    var b = a.slice(-4)
    b == "4321" ? "than do this" : "or do that"
    

    Rainer
    rg@delos-consulting.com

    0
    Comment actions Permalink
  • Edwin Martin

    thank you!

    0
    Comment actions Permalink
  • Adrien BLAISE

    If you just need to check whether a string contains a aubstring ("4321", regardless of its position), you can use:

    var a = @Field.indexOf("4321")
    a > -1 ? "Action if true" : "Action if false"
    
    0
    Comment actions Permalink
  • Rikke Olesen

    hi,

    I need the samt only based on the two first of "4085500 PUV" in this case "40"
    What should I write?

     

    0
    Comment actions Permalink
  • Rainer Grabowski

    Hi RIkke,

    var text = @Name of the field where the id is in;
    var first2 = text.substr(0,2);
    first2 == "40" ? do this : do that
    0
    Comment actions Permalink
  • Rikke Olesen

    Hi,

    I can't get it to work. Can you help once again.

    Fieldname for collecting date filtrede on the two first words are "[(Ref Item no.) Artwork no.]" 
    Filer on "40", "41" and "42" ect.

    I nedd til pull tekst from "[(Ref Item no.) Tekst]"

    Thanks

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk