? conditional

  • hi I want to do this

    BASIS_IND == "A" ? ||BASIS_IND == "T" ? : "Comp A" "Comp T" : "Comp"

    but I keep getting an error

    what im trying to do is set a - coma t = to compt and anything that's not a or t just set it to comp. whats the best way to do this

  • Try removing the first question mark.

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

  • hi

    no taking out first ? doesn't work

    when I used this I get an error

    BASIS_IND == "A" ||BASIS_IND == "T" ?: "Comp A": "Comp T" : "Comp"

  • The basic syntax is as follows:

    boolean_expression?expression1:expression2

    Your expression

    BASIS_IND == "A" ||BASIS_IND == "T" ?: "Comp A": "Comp T" : "Comp"

    has an 'expression3' - which I imagine is causing the error. (In future, kindly post the error message too.)

    This would probably work:

    (BASIS_IND == "A" ||BASIS_IND == "T)?: "Comp A": "Comp T"

    Can you state your desired logic in English? Perhaps I can help you achieve what you want.

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

  • ok is there anyway I cant put the 3 rd expression in as anything that's not a or t I just want as comp

  • ronan.healy (9/8/2014)


    ok is there anyway I cant put the 3 rd expression in as anything that's not a or t I just want as comp

    There is no need for a third expression. Consider

    boolean_expression?expression1:expression2

    Expression1 is evaluated if boolean_expression is true.

    If not, Expression2 is evaluated.

    There is no way that neither of the expressions would be evaluated.

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

  • Perhaps something like this?

    BASIS_IND == "A" ||BASIS_IND == "T" ?: "Comp " + BASIS_IND : "Comp"

    You might need to use & instead of + to concatenate the text - can't remember which works.

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

  • ill probably have to use an sql script to update the columns as that doesn't get all 3 in for me

  • ronan.healy (9/9/2014)


    ill probably have to use an sql script to update the columns as that doesn't get all 3 in for me

    Please explain why not.

    I thought you wanted Comp A, Comp T and Comp. My expression should do that.

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

  • sorry that did work. thought I replied ti this

Viewing 10 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic. Login to reply