Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

berryandcherry6
Contributor II

Count with where condition in qlik

Hi,

i have a below code

LatestExpiredCampaignTable:

LOAD

MAX(expiration_date) as expiration_date,

'1' as expFlag,

batch_meta_data_id,

1 as last_batch

Resident MainTable

where expFlag = 1

Group By batch_meta_data_id;

Load expiration_date,

batch_meta_data_id,

expFlag,

last_batch,

count(DISTINCT expiration_date) as count_value

resident LatestExpiredCampaignTable  where expFlag = 1 and last_batch = 1

Group By batch_meta_data_id;

drop Table LatestExpiredCampaignTable;

In above code i am trying to get count of expired_date i.e count_value, then i want to check like

if(count_value >= 2)

/* Here i want to load only rows with expFlag = 0 */

else

/* i want to load all rows with expFlag = 1 or last_batch = 1*/

endif


But green colored above code gives me invalid expression. What i am missing here and how to load data according to if else condition.


Tags (1)
2 Replies
ahaahaaha
Honored Contributor

Re: Count with where condition in qlik

Hi,

Maybe when using a grouping, you need to apply the aggregation functions for all the fields in second table?

Regards,

Andrey

berryandcherry6
Contributor II

Re: Count with where condition in qlik

Hi Andrey,

Thanks for reply. That was a good hint

After that i want to create table with requirement

if(count_value >= 2)

/* Here i want to load only rows with expFlag = 0 */

else

/* i want to load all rows with expFlag = 1 or last_batch = 1*/

endif


How could i do this?


Community Browser