Discussion board where members can get started with Qlik Sense.
I have a numeric value (a number of days related to late delivery) being read in from our ERP database and would like a new field in Qlik to be available, set based on this value.
Using load editor, can i setup a 'category' value using logic like this?
If no-of-days-late <= 7 then category = '1' Else
If no-of-days-late >= 8 and no-of-days-late <= 14 then category = '2' Else
If no-of-days-late >= 15 and no-of-days-late <= 20 then category = '3' Else
category = '4'
I'm sure this type of situation is what the load/declare statements are for(?) but I can't figure out quite how to do this.
In Load Script,
If ( no-of-days-late <= 7, '1',
If (no-of-days-late >= 8 and no-of-days-late <= 14, '2' ,
If( no-of-days-late >= 15 and no-of-days-late <= 20 , '3' ,'4'))) as Category
Thanks for your reply.
Can you please help to show this in context, as I don’t follow, sorry.
My script is shown below. The field I’m trying to use is actually ‘OtifDays’.
To make the example simpler, if I want a new field of ‘OtifCategory’, to be ‘1’ if ‘OtifDays’ is <=7 and ‘2’ if >7, how would this look in the code?
Where do I put in the script and where does the value ‘OtifCategory’ become available, as an available dimension in my sheet?
Do I use ‘LOAD’ or ‘SET’ or another command?
I appreciate your help.
SET TimestampFormat='DD/MM/YYYY hh:mm:ss[.fff]';
LIB CONNECT TO 'Microsoft_SQL_Server_ceuk-ep9-dbase';
If ( OtifDays <= 7, '1',
If (OtifDays>= 8 and OtifDays<= 14, '2' ,
If( OtifDays>= 15 and OtifDays <= 20 , '3' ,'4'))) as OtifCategory,
Fantastic, thank you very much. .
It's much clearer now. I wasn't understanding to include in the existing load statement