5 Replies Latest reply: Nov 24, 2015 2:09 AM by jagan mohan rao appala

# Adding two different values in set analysis

Hi all,

I have two set expressions which get two different counts of different campaigns. Now, i need to add the two counts.

Expressions:

1)  IF(match(Metrics, 'List Size'),sum({\$<email_type_id = {44}, campaign_name_id = {"\$(=max(campaign_name_id)-11)"}>}delivered))

2)  IF(match(Metrics, 'List Size'),sum({\$<email_type_id = {44}, campaign_name_id = {"\$(=max(campaign_name_id)-9)"}>}delivered))

I need to add the counts of two different Campaign_name_id's.

I used like below but not working

IF(match(Metrics, 'List Size'),sum({\$<email_type_id = {44}, campaign_name_id = {"\$(=max(campaign_name_id)-11)","\$(=max(campaign_name_id)-9)"}>}delivered),

Thanks,

Kuamr

• ###### Re: Adding two different values in set analysis

Hi Kumar Pramod,

Did you try like this,

IF(match(Metrics, 'List Size'),sum({\$<email_type_id = {44}, campaign_name_id = {"\$(=max(campaign_name_id)-11)"}>}delivered))

+

IF(match(Metrics, 'List Size'),sum({\$<email_type_id = {44}, campaign_name_id = {"\$(=max(campaign_name_id)-9)"}>}delivered))

• ###### Re: Adding two different values in set analysis

Hi,

Try like this

sum({\$<Metrics={'List Size'}, email_type_id = {44}, campaign_name_id = {"\$(=max(campaign_name_id)-11)", "\$(=max(campaign_name_id)-9)"}>}delivered)

Hope this helps you.

Regards,

jagan.

• ###### Re: Adding two different values in set analysis

Hi jagan,

Is any other way i can get the campaign_name_id as now i am using

campaign_name_id = {"\$(=max(campaign_name_id)-11)"}

without hard coding -11, because if any other new campaign is added then it will fetch the data of other campaign.

I have attached the sample data,

My campaign starts on every tuesday and ends on sunday.

For example today new campaign is started, now i need the last campaign data.

how can i use the date fields in the table to get the last campaign_name_id values?

• ###### Re: Adding two different values in set analysis

did you think about using a variable for that "-11" and use qsVariable for adding the Campaign you want?

you could pre-define your campaigns there or just give a field where to add the number of the campaign you want to see

qsVariable (this is the Qlik Branch Link)

Regards

Chris

• ###### Re: Adding two different values in set analysis

Hi Kumar,

You can try

=max(campaign_name_id, 2) to get previous campaign data always.  -- for attached file you always get 64