Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello
I have this script snippet in Qlik; I just want to know if there is a better approach to this or is this fine?
if(Ceil(Today() - floor(CASE_CREATED_DATE)) <= 1, '1D',
if(Ceil(Today() - floor(CASE_CREATED_DATE)) > 1 and Ceil(Today() - floor(CASE_CREATED_DATE)) <= 2, '2D',
if(Ceil(Today() - floor(CASE_CREATED_DATE)) > 2 and Ceil(Today() - floor(CASE_CREATED_DATE)) <= 7, '1W',
if(Ceil(Today() - floor(CASE_CREATED_DATE)) > 7 and Ceil(Today() - floor(CASE_CREATED_DATE)) <= 14, '2W',
if(Ceil(Today() - floor(CASE_CREATED_DATE)) > 14 and Ceil(Today() - floor(CASE_CREATED_DATE)) < $(vAgeingMax1M), '1M',
if(Ceil(Today() - floor(CASE_CREATED_DATE)) >= $(vAgeingMax1M) and Ceil(Today() - floor(CASE_CREATED_DATE)) < $(vAgeingMax2M), '2M',
if(Ceil(Today() - floor(CASE_CREATED_DATE)) >= $(vAgeingMax2M) and Ceil(Today() - floor(CASE_CREATED_DATE)) < $(vAgeingMax3M), '3M',
if(Ceil(Today() - floor(CASE_CREATED_DATE)) >= $(vAgeingMax3M), '> 3M'))))))))
as CASE_AGE,
I think a pick(match()) would be better in regard to the overview and performance. It means something like:
pick(match(Ceil(Today() - floor(CASE_CREATED_DATE)), 0,1,2,3,...),
'1D', '1D', ....)
- Marcus
You could calculate the date difference first and then in a preceding load classify the date differences.
LOAD
*,
If( DateDiff <=1, '1D',
If( DateDiff <=2, '2D'
If( DateDiff <=7, '1W',
...etc... as CASE_AGE
;
LOAD
...lots of fields,
Ceil(Today() - floor(CASE_CREATED_DATE)) as DateDiff
FROM
...source...
;
Minimize the expression by using variables, like
LET vDate = Ceil(Today() - floor(CASE_CREATED_DATE);
And use this.