Forum Discussion

katness's avatar
katness
Regular Visitor
4 years ago
Solved

Logical Operators &&& || IN do not work

Hi,  I'm trying to accomplish a fairly simple Case statement in PBI lingo but the logical operators are not working at all.  Is there something with the version that I am on?  How do I fix this?   ...
  • TheoC's avatar
    4 years ago

    Hi there,

     

    I believe this is because you are using Power Query to create a Custom Column rather than using Power BI Desktop's front end to create a Calculated Column.

     

    Note that Power Query uses the M language.  The front end of Power BI Dekstop uses DAX which incorporates logical operators, etc.

     

    Hope this helps.


    Theo 🙂

  • mahoneypat's avatar
    4 years ago

    The &&, || and IN syntax is for DAX and that is an M expression.  This should work instead.  You may find it frustrating/confusing, but stick with it.  It's worth it.  Note too that M is case sensitive, so the and is all lowercase.

     

    if List.Contains({"RBCCM","CITIGMI"}, [Counterparty]) then "EXCH"

    else if [Wholesale or Retail] = "WHOLESALE" and [MANUM] <> "INTERBOOK"

    and [Risk Trade Type] <> "PHYSICALS"

    and not List.Contains({"RBCCM","CITIGMI","PJM","ISONE"}, [Counterparty]) then "OTC" else "OTHER"

     

    Pat