Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Error with if statement

Hi,   I have the following if statement   Missed Deadlines = if('Maintenance Ticket System'[Status] = "Critical" & 'Maintenance Ticket System'[JobStarted]>1,"Missed", if('Maintenance Ticket Sys...
  • ribisht17's avatar
    4 years ago

    Anonymous 

     

    Solved: DAX comparison operations do not support comparing... - Microsoft Power BI Community

     

    You need to use double ampersand '&&' between your logical arguments. A single ampersand simply tries to concatenate text.

    I'd also recommend using the SWITCH function in place of your nested IF statements as it makes the code easier to read.

     

    Weekly Service Charge =
    SWITCH (
        TRUE (),
        UnitCharge[ChargeFrequencyRef] = "M"
            && DATESBETWEEN ( UnitCharge[StartDate], 01 / 04 / 2018, 01 / 04 / 2019 )
            && UnitCharge[ChargeTypeId] = 2, UnitCharge[ChargeAmount] * 12 / 52,
        UnitCharge[ChargeFrequencyRef] = "Q"
            && DATESBETWEEN ( UnitCharge[StartDate], 01 / 04 / 2018, 01 / 04 / 2019 )
            && UnitCharge[ChargeTypeId] = 2, UnitCharge[ChargeAmount] * 4 / 52,
        UnitCharge[ChargeFrequencyRef] = "Y"
            && DATESBETWEEN ( UnitCharge[StartDate], 01 / 04 / 2018, 01 / 04 / 2019 )
            && UnitCharge[ChargeTypeId] = 2, UnitCharge[ChargeAmount] / 52,
        UnitCharge[ChargeFrequencyRef] = "W"
            && DATESBETWEEN ( UnitCharge[StartDate], 01 / 04 / 2018, 01 / 04 / 2019 )
            && UnitCharge[ChargeTypeId] = 2, UnitCharge[ChargeAmount]
    )

    Regards,
    Ritesh
    Mark my post as a solution if it helped you| Munde and Kudis (Ladies and Gentlemen) I like your Kudos!! !!
    My YT Channel Dancing With Data !! Connect on Linkedin !!Power BI for Tableau Users