Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Can I use AND/OR fields in SWITCH?

Hello

 

I have the table:

1, A, E

2, B, F

 

I want to specify a value, when Column2=A and Column3=E.

 

Can I do that with SWITCH or do I need IF?

 

Thanks!

  • Anonymous ,

    If([column2] ="A" && [column3] ="3",1,0)

     

    switch(true(),

    [column2] ="A" && [column3] ="3",1

    ,0)

    For Or Use ||

4 Replies

  • Anonymous 

     

    I think it works

    Column = SWITCH(TRUE(),'Table'[Column1]="A" && 'Table'[Column2]="E","yes")

    Then I did a test to change a to b, the result is blank.

    hope this is helpful.

  • Anonymous ,

    If([column2] ="A" && [column3] ="3",1,0)

     

    switch(true(),

    [column2] ="A" && [column3] ="3",1

    ,0)

    For Or Use ||

  • Anonymous ,

    Try the below Code:

    Column = IF('Table'[Column1]="A" && 'Table'[Column2]="E","YES","NO")

     

  • v-alq-msft's avatar
    v-alq-msft
    Icon for Community Support rankCommunity Support

    Hi, Anonymous 

     

    Based on your description, I created data to reproduce your scenario.
    Table:

     

    You may create a measure as below to control the display of the visual.

    Visual Control = 
    IF(
        SELECTEDVALUE('Table'[Column2])="A"&&
        SELECTEDVALUE('Table'[Column3])="E",
        1,0
    )

     

    Then you need to put the measure in the corresponding visual level filter to get the result.

     

    Best Regards

    Allan

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.