Forum Discussion

Gdibbs's avatar
Gdibbs
Helper I
4 years ago
Solved

Conditional Column in Dax not calculating as expected

Hi All,   I suspect I am missing something very basic and/or obvious.   I am trying to do the following...   If the column headered "plant" is equal to "US5A" and the month headered "Oct-21" is...
  • AllisonKennedy's avatar
    4 years ago

    Gdibbs , a couple of things:

     

    1) M is case sensitive and spelling counts. You've written two different things: 

    • [Plant]] = "AS5A" 
    • "plant" is equal to "US5A"

    Which option do you want? A or U?

    2) It's difficult to see with your screenshots, as you haven't included the columns in one shot, but the example you did show does not appear to have any data < 1, so that will leave everything as blank (not null - if you want null you need to specify that in your column instead of the empty quotes "").

     

    = Table.AddColumn(#"Filtered Rows", "Custom", each if [[Plant]] = "AS5A" and ([[#"Oct-21"]] < 1) then ([#"Oct-21"] * -1) else null)

     

    Otherwise I can't see any obvious errors at a quick glance.