Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

If Condition

TALK_DURATION,

TALK_DURATION/60 as talk_duration_min,

     if(talk_duration_min=0,0,talk_duration_min) as clus

     Hello everbody I have written the above mentioned script in Load statment but unfortunately I am unable to load the script due top below mentioned error.

Error:Field not found - <talk_duration_min>

Need your kind support.

Plus I have different value from 0 to 54 in  talk_duration_min the main thing is I want to make a cluster. like

0-1 min

2-5 min

6-10 min

11-15min

16-20 min

>20min

1 Solution

Accepted Solutions
its_anandrjs

Yes because your expression condition is not correct try with

Load

TALK_DURATION,

if((TALK_DURATION / 60) = 0, '1min',

if((TALK_DURATION / 60) >= 1 and (TALK_DURATION / 60) <= 5,'1-5min',

TALK_DURATION/60))   as clus

From Location;

If possible share sample file.

Regards

Anand

View solution in original post

9 Replies
MK_QSL
MVP
MVP

Try as below

TALK_DURATION,

TALK_DURATION/60 as talk_duration_min,

if(TALK_DURATION/60=0,0TALK_DURATION/60) as clus

MK_QSL
MVP
MVP

Load

     *,

     If(clus >0 and clus <=1, '0-1 min',

     If(clus >1 and clus <=5, '2-5 min',

     If(clus >5 and clus <=10, '6-10 min',

     If(clus >10 and clus <=15, '11-15 min',

     If(clus >15 and clus <=20, '16-20 min','>20 min')))));

Load

     TALK_DURATION,

     TALK_DURATION/60 as talk_duration_min,

     if(TALK_DURATION/60=0,0TALK_DURATION/60) as clus

From TableName;

its_anandrjs

     TALK_DURATION,

    TALK_DURATION/60 as talk_duration_min,

     if(talk_duration_min=0,0, TALK_DURATION/60 ) as clus

Before rename expression used in the script.

Regards

Anand

Not applicable
Author

Thanks everbody for the supprot. But unfortunately it didnot workout. Only  below mentioned query worked but for one calcuation but I need 4 other if statements as well

if(TALK_DURATION/60=0,'1min',TALK_DURATION/60) as clus

Not applicable
Author

Is it not possible to write somthing like

if(TALK_DURATION/60=0,'1min',TALK_DURATION/60, if(TALK_DURATION/60 >=1 and <=5, '1-5min', TALK_DURATION/60))   as clus

it gives an error

Error in expression:

')' expected

MK_QSL
MVP
MVP

Load

     *,

     If(clus >0 and clus <=1, '0-1 min',

     If(clus >1 and clus <=5, '2-5 min',

     If(clus >5 and clus <=10, '6-10 min',

     If(clus >10 and clus <=15, '11-15 min',

     If(clus >15 and clus <=20, '16-20 min','>20 min'))))) as Flag;

Load

  TALK_DURATION,

  Time(Time#(Num#(TALK_DURATION,'#0'),'ss'),'m') as talk_duration_min,

  if(TALK_DURATION/60=0,0,TALK_DURATION/60) as clus

Inline

[

  TALK_DURATION

  100

  120

  75

  40

  150

  180

  10

  15

  500

  1000

  2000

];

its_anandrjs

Yes because your expression condition is not correct try with

Load

TALK_DURATION,

if((TALK_DURATION / 60) = 0, '1min',

if((TALK_DURATION / 60) >= 1 and (TALK_DURATION / 60) <= 5,'1-5min',

TALK_DURATION/60))   as clus

From Location;

If possible share sample file.

Regards

Anand

Not applicable
Author

Thank you Anand Chouhan, The mistake you pointed out was acutally the pain point. I appericate everbody else for the support as well.

its_anandrjs

Thanks Glad the help you

Regards

Anand