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: 
Not applicable

IF statement in expression

Hi everybody,

I have a question using a IF statement in an expression. I'm not sure this is a possible way or even the best way, but after 2 days trying and failing, the time has come to search for expert help.

The case is; In my QlickView I have one row of measurements given from our customers. The name of this row is "Height".

In row 2 I have information of what the height really was after a controll measurement done by my colleagues. The name of this row is “RealHeight”.On top of that, I have a row with tolerances, based on the type of packaging.  The names of those two rows are “Tolerances” and “Packaging”.

I want to make a check if the given “Height” from our customers is inside or outside the measurement done by our colleagues +/- the tolerance by setting 1 when the height is outside the tolerances and 0 when it is inside the tolerances.

I’ve tried this IF-statement, but it doesn’t give me the expected result.

SUM(IF((RealHeight + Tolerances) > Height, 0,
    
IF((RealHeight -Tolerances)< Height, 0, 1)))

Any ideas?

4 Replies
jjfabian
Partner - Creator III
Partner - Creator III

Hi,

try adding more brackets.

SUM(IF(((RealHeight + Tolerances) > Height), 0,
    
IF(((RealHeight -Tolerances)< Height), 0, 1)))

Does this help?

Not applicable
Author

Unfortunately, the result is the same.

Thanks anyway.

Not applicable
Author

Hi,

Try this

IF(Sum(RealHeight + Tolerances) > Sum(Height), 0,
    
IF(Sum(RealHeight -Tolerances)< Sum(Height), 0, 1)))

 

Not applicable
Author

The result appears to be the same.

If I run this statement alone, I've got an correct count for all products outside the maximum tolerances:

IF(Sum(RealHeight + Tolerances) > Sum(Height), 0, 1)

but the combination between maximum tolerances and minimum tolerances would not work.