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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

How can I fix this error in DAX code?

The below is a column created with DAX, which checks whether the value in the "Value" column is more than the "Min" column and less than the "Max" column, and will will display "In Limits" if this is the case and "OOL" otherwise. I have also excluded rows 91/92/93/94, which will always display In Limits. However, a problem arises because sometimes the value column does not have a decimal number but the string "NA" instead which returns an error when it tries to do the greater/less than operation. Is there a way to write a condition so that if it is NA in the value column, just mark it as "Not Running" rather than in limits/ool? i.e. run the below condition, but if Panel[Value]="NA", don't run the below condition and just mark CL OOl column with "not Running"

 

 

CL OOL = IF(AND(Panel[Value] >= Panel[Min], Panel[Value] <= Panel[Max]) || Panel[Index] = 91 || Panel[Index] = 92 || Panel[Index] = 93 || Panel[Index] = 94 ||, "In Limits", "OOL")

 

 

1 ACCEPTED SOLUTION

@Anonymous , Try this one:-

CL OOL =
SWITCH (
    TRUE (),
    AND (
        IFERROR ( INT ( Panel[Value] ), "Not Running" ) >= Panel[Min],
        IFERROR ( INT ( Panel[Value] ), "Not Running" ) <= Panel[Max]
    )
        || Panel[Index] IN { 91, 92, 93, 94 }, "In Limits",
    IFERROR ( INT ( Panel[Value] ), "Not Running" ) = "Not Running", "Not Running",
    "OOL"
)

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

View solution in original post

8 REPLIES 8
Tahreem24
Super User
Super User

@Anonymous ,Try this code:

 = SWITCH(TRUE(),
Value>=Min && Value<=Max,"In Limits",
Panel[Index] = 91 || Panel[Index] = 92 || Panel [Index] = 93 || Panel[Index] = 94,"In Limits",
Value="NA","Not Running","OOL")

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard
Anonymous
Not applicable

Hi @Tahreem24 , it gave the error "The syntax for '&&' is incorrect". Here is a picture of my data if it helps. Ignore columns with cross. 

 

XYZ1233_0-1646645600164.png

 

Samarth_18
Community Champion
Community Champion

Hi @Anonymous ,

 

Pls try this:-

CL OOL =
SWITCH (
    TRUE (),
    AND ( INT ( Panel[Value] ) >= Panel[Min], INT ( Panel[Value] ) <= Panel[Max] )
        || Panel[Index] IN { 91, 92, 93, 94 }, "In Limits",
    Panel[Value] = "NA", "Not Running",
    "OOL"
)

 

Thanks,

Samarth

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Anonymous
Not applicable

Hi @Samarth_18 ,

 

Your code gave this error: "Cannot convert value 'NA' of type Text to type Number". My Value column has type text because it holds both numbers and "NA" values. 

@Anonymous ,Pls try now:-

CL OOL =
VAR result =
    IF (
        AND ( INT ( Panel[Value] ) >= Panel[Min], INT ( Panel[Value] ) <= Panel[Max] )
            || Panel[Index] IN { 91, 92, 93, 94 },
        "In Limits",
        "OOL"
    )
RETURN
    IFERROR ( result, "Not Running" )

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Anonymous
Not applicable

Thanks @Samarth_18 ,

 

It still seems to return the same error though. Here is a picture of some of my data if it helps.

XYZ1233_0-1646646465313.png

 

@Anonymous , Try this one:-

CL OOL =
SWITCH (
    TRUE (),
    AND (
        IFERROR ( INT ( Panel[Value] ), "Not Running" ) >= Panel[Min],
        IFERROR ( INT ( Panel[Value] ), "Not Running" ) <= Panel[Max]
    )
        || Panel[Index] IN { 91, 92, 93, 94 }, "In Limits",
    IFERROR ( INT ( Panel[Value] ), "Not Running" ) = "Not Running", "Not Running",
    "OOL"
)

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Anonymous
Not applicable

Thanks, it works now!

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.