Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

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 System'[Status] = "High" & 'Maintenance Ticket System'[JobStarted]>2,"Missed",
if('Maintenance Ticket System'[Status] = "Medium" & 'Maintenance Ticket System'[JobStarted]>3,"Missed",
if('Maintenance Ticket System'[Status] = "Low" & 'Maintenance Ticket System'[JobStarted]>5,"Missed",""))))

 

However I am getting the error

 

DAX comparison operations do not support comparing values of type True/False with values of type Integer. Consider using the VALUE or FORMAT function to convert one of the values.

 

Any help?

 

 

1 ACCEPTED SOLUTION
ribisht17
Community Champion
Community Champion

@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 

View solution in original post

4 REPLIES 4
ribisht17
Community Champion
Community Champion

@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 
Anonymous
Not applicable

Hi @ribisht17 

 

That has not resolved the comparison issue. any idea?

what is the new error ?

Anonymous
Not applicable

Same as the old one - it seems to not like the comparison having text and integer.

 

Even tried

 

Missed Deadlines =
SWITCH (
    TRUE (),
    'Maintenance Ticket System'[Status] = "Critical"
        && 'Maintenance Ticket System'[JobStarted]>1,"Missed",
    'Maintenance Ticket System'[Status] = "High"
       && 'Maintenance Ticket System'[JobStarted]>2,"Missed",
    'Maintenance Ticket System'[Status] = "Medium"
    && 'Maintenance Ticket System'[JobStarted]>3,"Missed",
    'Maintenance Ticket System'[Status] = "Low"
    && 'Maintenance Ticket System'[JobStarted]>5,"Missed"
)

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.