Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

IF with multiple conditions

Hi everyone, I am trying to create an if statement where I have multiple conditions, but I don't know how to use it

 

Measure =
SWITCH(
    TRUE(),
    CALCULATETABLE(TBL,TBL[C] = "\N" && TBL[C] = "2" && TBL[C] = " " && TBL[C] = "AL" && TBL[C] = "A" && TBL[C] = "AS" && TBL[C] = "CS" && TBL[C] = "EDS" && TBL[C] = "HQ", "OK", "New Value"))
 
I want if the column has any if this values then is ok if it has somehting different is a new valie

3 Replies

  • The colloquial "I need AL and AS and A and CS" translates into an OR statement  (otherwise nothing would be returned).

     

    Instead of multiple ORs you can use IN and enumerate a list.

     

    Measure = IF(TBL[C] IN { "\N","2"," ","AL","A","AS","CS","EDS","HQ"}, "OK", "New Value")
    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi, in the case of "C" in the table is not a measure, should I add a "Calculate" before? 

       

      Measure = IF(Calculate(Sum(TBL[C] IN { "\N","2"," ","AL","A","AS","CS","EDS","HQ"}, "OK", "New Value")))

       

      Or how can I bring the column of the table? 

      • lbendlin's avatar
        lbendlin
        Super User

        You cannot sum text values.  Please provide sample data that fully covers your issue.
        Please show the expected outcome based on the sample data you provided.