Skip to main content
Announcements
See why Qlik was named a Leader in the 2024 Gartner® Magic Quadrant™ for Data Integration Tools for the ninth year in a row: Get the report
cancel
Showing results for 
Search instead for 
Did you mean: 
neha_sri
Creator III
Creator III

if condition not working properly

Hi everyone,

I am trying to run a query,but I am not getting the desired output.

LOAD

     COMPONENT_NAME,

     RESULT_VALUE,

     TEST_ID,

     if(upper(COMPONENT_NAME)='IRON AS FE',Count(if(RESULT_VALUE >=15,'5'))) as Ind

from result.qvd

Group by

     COMPONENT_NAME,RESULT_VALUE,TEST_ID;

But everytime it get 0,1 as Ind

Is there any pblm ion my script???

13 Replies
neha_sri
Creator III
Creator III
Author

I tried the above mentioned query but count returns only 0 and 1,nothing else.

jagan
Luminary Alumni
Luminary Alumni

Hi Neha,

I think it is not possible to calculate in backend, try like this

Load all the data and then use this Set Analysis expression

=Count({<COMPONENT_NAME={'IRON AS FE'}, RESULT_VALUE={'>15'}>} TEST_ID)

Regards,

jagan.

neha_sri
Creator III
Creator III
Author

Hi All,

I found the solution for this.

Final:

LOAD TEST_ID,

     COMPONENT_NAME,

     RESULT_VALUE,

     if(upper(COMPONENT_NAME)='IRON AS FE' and RESULT_VALUE >=15,RESULT_VALUE)  as Ind

     FROM

[RESULT.qvd]

(qvd);

temp:

load distinct Ind as IND1

Resident Final Where Exists (Ind);

let v_var=NoOfRows('temp');

load distinct *,'$(v_var)' as Count resident Final;

Here we can get the count at backend only.

jagan
Luminary Alumni
Luminary Alumni

Hi Neha,

Try this simple script

Source:

LOAD * INLINE [

    COMPONENT_NAME, RESULT_VALUE, TEST_ID

    IRON AS FE, 18, 299

    MN, 20, 768

    AG, 21, 578

    IRON AS FE, 24, 765

    IRON AS FE, 4, 676

];

Data:

LOAD

COMPONENT_NAME,

Count(TEST_ID) AS Result_GR_15

RESIDENT Source

WHERE COMPONENT_NAME = 'IRON AS FE' AND RESULT_VALUE > 15

GROUP BY COMPONENT_NAME;

Regards,

jagan.