Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
SET_Padawan
Contributor III
Contributor III

Expression is said to have an error, but outputs a value anyway

When I use nested IFs in this manner, I keep seeming to get an error message. But it ends up outputting a value anyway, and the value seems to be correct. Although one time it just randomly stopped working on one chart, but then copy and pasting the expression from another chart made it work again. Can someone take a look at my expression and help me find out what is supposedly wrong with it? 

=Sum(
    If(Left(Item_Type, 1) = '2', 1,
        If(Left(Item_Type, 1) = '4', 2, 
            If(Left(Item_Type, 1) = 'L', 2.25,
                If(Left(Item_Type, 1) = 'M', 2.4, Null)
            )
        )
    )
)

 Basically I'm trying to convert text values to a corresponding numerical value based on the first character of the string.

Labels (1)
1 Solution

Accepted Solutions
avinashelite

Error is because of the NULL direct value , try like this 

=Sum(
If(Left(Item_Type, 1) = '2', 1,
If(Left(Item_Type, 1) = '4', 2,
If(Left(Item_Type, 1) = 'L', 2.25,
If(Left(Item_Type, 1) = 'M', 2.4, Null())
)
)
)
)

View solution in original post

2 Replies
avinashelite

Error is because of the NULL direct value , try like this 

=Sum(
If(Left(Item_Type, 1) = '2', 1,
If(Left(Item_Type, 1) = '4', 2,
If(Left(Item_Type, 1) = 'L', 2.25,
If(Left(Item_Type, 1) = 'M', 2.4, Null())
)
)
)
)

SET_Padawan
Contributor III
Contributor III
Author

Thanks for this @avinashelite !