Discussions

Expand all | Collapse all

How to create a if statement using the first 4 char of a text field

  • 1.  How to create a if statement using the first 4 char of a text field

    Posted 03-13-2017 14:29
    I need help trying to create an if state using the first 3 or 4 char of a text field

    For example if  [text field 1] start with 7083 = 083
                             [text field 1] start with 083 = 083


  • 2.  RE: How to create a if statement using the first 4 char of a text field

    Posted 03-13-2017 14:40

    assuming the string you're checking is text, the formula field may go something like:

    if(

    begins([field],"7083"),"083",

    begins([field],"083"),"083"

    )

    The Begin() function works on text fields, so if you're comparing numbers, you'd have to use the ToText() fuction around the expression.


    This link may help you with formula functions:

    https://login.quickbase.com/db/6ewwzuuj?a=q&qid=6">https://login.quickbase.com/db/6ewwzuuj?a=q&qid=6">https://login.quickbase.com/db/6ewwzuuj?a=q&qid=6




  • 3.  RE: How to create a if statement using the first 4 char of a text field

    Posted 03-13-2017 14:43
    To show just the left most characters you can use the formula "Left"

    Left([text field], 3)  will return the left 3 characters.

    Combine that with your if like this:

    If(Left([Text Field], 3)="083", "Result if true", "result if false")

    Then to combine both of those to evaluate options you can "daisy chain" them together:

    If(Left([Text Field], 3)="083", "083",
    If(Left([Text Field], 4)="7083", "083", "result if neither is true"))