Conditional functions
Often in QlikView, you want to modify the data based on a condition. For example, we may want to classify any aircraft that was present in the database before 1990 as "Classic", and classify everything from 1990 onward as "Current". Let's open the script editor and see how this is done:
Locate the
[Aircraft Types] LOAD
statement.Add a comma behind the line
END_DATE as [Aircraft End Date]
and press Return to create a new line.On the new line, put the following expression:
If(Year(BEGIN_DATE) < 1990, 'Classic', 'Current') as [Aircraft Age Classification]
As the 2010 update only contains aircraft that are newer than 2010, we do not need to use the conditional expression, instead we can use a fixed value.
Add a comma behind the line
END_DATE as [Aircraft End Date]
and press Return to create a new line.Put the following expression on this line:
'Current' as [Aircraft Age Classification]
Save and reload the document.
Add Aircraft Age Classification field to the Aircraft...