Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
trishita
Creator III
Creator III

How and where to write conditional statement in qlikview

I have two fields .

Deviation after sounding and Difference vs Log survey:

I want to write a code that if the  difference between them is less than 2 then a new column will display yes against the value or else no.

if (Deviation after sounding) - (Difference vs Log survey) <=2 then (NEW COLUMN ) = "Correction done"

or else "Correction Not Done"

10 Replies
m_woolf
Master II
Master II

In script:

if(rangesum([Deviation after sounding],-[Difference vs Log survey])<=2,'Correction done','Correction not done') as NewField

vishsaggi
Champion III
Champion III

Did you try like:

LOAD field1, field2,

           if ((Deviation after sounding - Difference vs Log survey) <=2, "Correction done", "Correction Not Done") AS NewFieldName

FROM yoursourceTableName;

trishita
Creator III
Creator III
Author

I have not done it in the table as the two fields are coming from different tables

trishita
Creator III
Creator III
Author

Why do we need rangesum? Can I do it in the edit expression of chart properties(as I am using a standard table chart)

m_woolf
Master II
Master II

You need rangesum if either of the two fields can ever be null. F1-F2 will yield null if either is null.

Yes, you can do it in a chart expression. Generally it is better (faster) to do as many calculation is script as is feasible.

trishita
Creator III
Creator III
Author

Hi I tried with the following code:

if(rangesum(SoundingCorrections.DEVIATION_AFTER_SOUNDING,-[Summary.Difference Log vs Survey])>= 0,'Correction done','Correction not done')

DEVIATION AFTER SOUNDING HAS THE FOLLWOING VALUES. = -42,  -42,  -42,  -42

Difference Log vs Survey HAS THE FOLLWOING VALUES = 0,  -42.68,  -16,  -7.89

But for all the values they are showing 'Correction Not Done' Which should not be true as the second value is clearly greater than 0

m_woolf
Master II
Master II

Add an expression:

rangesum(SoundingCorrections.DEVIATION_AFTER_SOUNDING,-[Summary.Difference Log vs Survey])


so you can see the values.


Can you share the qvw?

vishsaggi
Champion III
Champion III

Can you share your data model and the script you are trying?

shiveshsingh
Master
Master

Can you share the data and script?