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

Creating a binary flag

Have a requirement,need to create a field in the script wth 3 defined range so that if it's 1st range it Shud give 1 else 2 or 3 ,how to do that.

5 Replies
prieper
Master II
Master II

create an expression like

LOAD

*,

IF(MyCheckField < 100, 1, IF(MyCheckField < 1000, 2, 3))          AS Range

FROM ....;

Edith would like to add that a field with content 1, 2, 3 is not a binary field ...

Peter

vinieme12
Champion III
Champion III

can you give an example?

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
Anonymous
Not applicable
Author

ok and also i would like to create this field as it doesnt exist in my script.

how to and where to do that.

Peter_Cammaert
Partner - Champion III
Partner - Champion III

Or without nested IF() calls:

LOAD ...

     Match(-1, FieldToCheck<1000, FieldToCheck<2000, FieldToCheck>=2000) AS Flag,

...

The ranges can be made variable by defining two border variables and $-sign substituting them in the Match() call.

Best,

Peter

Peter_Cammaert
Partner - Champion III
Partner - Champion III

In Peter's example, the field is created in the script as Range.

You can't create fields outside of your load script.

You can however create a value column on the fly in an UI object by using the same expression without the AS Range part in a Calculated dimension or a simple expression column.