Forum Discussion

MurielT's avatar
MurielT
Frequent Visitor
9 years ago
Solved

How to use the OR Operator with DAX

Hi

Can someone please help me to capture the accurate expression on DAX.

I would like to use the OR operator for multiple values like below but sounds I do something bad as I have an error message.

Thanks,

 

FILTER (
'Product'[Product Line Identifier] = "6J" ||
'Product'[Product Line Identifier] = "2C" ||
'Product'[Product Line Identifier] = "KV")
)

  • MurielT

     

    Hi,

    It seems something is wrong with the other part of your formula. Please post your formula here. You can replace the confidential part. Or maybe you can try operator “in” like this: 'Product'[Product Line Identifier] in {“6J”, “2C”, “KV”}  (Values in brace).

     

    Best Regards!

    Dale

8 Replies

  • v-jiascu-msft's avatar
    v-jiascu-msft
    Microsoft Employee

    MurielT

     

    Hi,

    It seems something is wrong with the other part of your formula. Please post your formula here. You can replace the confidential part. Or maybe you can try operator “in” like this: 'Product'[Product Line Identifier] in {“6J”, “2C”, “KV”}  (Values in brace).

     

    Best Regards!

    Dale

  • Anonymous's avatar
    Anonymous
    Not applicable

    Your OR statement is perfectly fine. You've just left out the first argument of your FILTER function.

     

    FILTER(<table>, <conditional statement>)

     

     

    What you've done is

     

    FILTER(<conditional statement>)

     

    So you should write

     

    FILTER (

    'Product',
    'Product'[Product Line Identifier] = "6J" ||
    'Product'[Product Line Identifier] = "2C" ||
    'Product'[Product Line Identifier] = "KV")
    )

    • MurielT's avatar
      MurielT
      Frequent Visitor

      Thanks for your reply

      However it does not work.

      My Table is "Product"

      My field is "Product Line Identifier"

       

      May I need to add a function like EVALUATE ?

       

      Thanks

      Muriel

       

      • Anonymous's avatar
        Anonymous
        Not applicable

        No you do not need EVALUATE. Show me the full formula you're using, not just the FILTER part. Is it a measure or a column?