Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Only at Qlik Connect! Guest keynote Jesse Cole shares his secrets for daring to be different. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to use When condition in the Edit Script

How do i use When condition in the edit script of qlikview ? Please do not suggest me to do this in Expressions. I want to add the condition in the edit script itself.Is this possible in below context? Please see the text marked in red below where i need the condition.

Following is the script,

LOAD date(Month,'MMM-YY') as Month,

     COD_MARKET as Market,

     Brand_Desc as Brand,

     [Source Channel],

     [Active Contacts],

     [Unique Leads last 6 Months],

     [Unique Leads 1 Month],

     [Unique Permissions],

     Total_Permission,

     Contacts,

     sum([Unique Leads 1 Month])/sum([Active Contacts]) as LeadsByActiveContacts (I want to add a condition to this expression for Market = Italy. How do i do this?  )

   

FROM

(ooxml, embedded labels, table is Sheet2)

Group By Month,

     COD_MARKET,

     Brand_Desc,

     [Source Channel],

     [Active Contacts],

     [Unique Leads last 6 Months],

     [Unique Leads 1 Month],

     [Unique Permissions], Contacts,Total_Permission;

1 Solution

Accepted Solutions
Kushal_Chawda

may be this

LOAD date(Month,'MMM-YY') as Month,

     COD_MARKET as Market,

     Brand_Desc as Brand,

     [Source Channel],

     [Active Contacts],

    Sum([Unique Leads last 6 Months]) as [Unique Leads last 6 Months],

     sum([Unique Leads 1 Month]) as [Unique Leads 1 Month],

     [Unique Permissions],

     Total_Permission,

     Contacts,

     sum(if(COD_MARKET='Italy',[Unique Leads 1 Month]))/sum(if(COD_MARKET='Italy',[Active Contacts])) as LeadsByActiveContacts  

FROM

(ooxml, embedded labels, table is Sheet2)

Group By Month,

     COD_MARKET,

     Brand_Desc,

     [Source Channel],

     [Active Contacts],

     [Unique Permissions], Contacts,Total_Permission;

Update : Do the sum for all the measures and remove from Group by.

View solution in original post

5 Replies
tamilarasu
Champion
Champion

Hi Maneck,

May be this,

Load ...

...

If(COD_MARKET = 'Italy' , sum([Unique Leads 1 Month])/sum([Active Contacts]), '') as LeadsByActiveContacts

From

...

Kushal_Chawda

may be this

LOAD date(Month,'MMM-YY') as Month,

     COD_MARKET as Market,

     Brand_Desc as Brand,

     [Source Channel],

     [Active Contacts],

    Sum([Unique Leads last 6 Months]) as [Unique Leads last 6 Months],

     sum([Unique Leads 1 Month]) as [Unique Leads 1 Month],

     [Unique Permissions],

     Total_Permission,

     Contacts,

     sum(if(COD_MARKET='Italy',[Unique Leads 1 Month]))/sum(if(COD_MARKET='Italy',[Active Contacts])) as LeadsByActiveContacts  

FROM

(ooxml, embedded labels, table is Sheet2)

Group By Month,

     COD_MARKET,

     Brand_Desc,

     [Source Channel],

     [Active Contacts],

     [Unique Permissions], Contacts,Total_Permission;

Update : Do the sum for all the measures and remove from Group by.

PabloOrtiz
Partner - Creator
Partner - Creator

Hello, maybe other way...

table:

LOAD date(Month,'MMM-YY') as Month,

     COD_MARKET as Market,

     Brand_Desc as Brand,

     [Source Channel],

     [Active Contacts],

     [Unique Leads last 6 Months],

     [Unique Leads 1 Month],

     [Unique Permissions],

     Total_Permission,

     Contacts,

     sum([Unique Leads 1 Month])/sum([Active Contacts]) as LeadsByActiveContacts

FROM

(ooxml, embedded labels, table is Sheet2)

WHERE COD_MARKET = 'Italy'

Group By Month,

     COD_MARKET,

     Brand_Desc,

     [Source Channel],

     [Active Contacts],

     [Unique Leads last 6 Months],

     [Unique Leads 1 Month],

     [Unique Permissions], Contacts,Total_Permission;

concatenate (table)

.....

LOAD date(Month,'MMM-YY') as Month,

.........

WHERE COD_MARKET <> 'Italy'

Group By Month,

     COD_MARKET,

     Brand_Desc,

     [Source Channel],

     [Active Contacts],

     [Unique Leads last 6 Months],

     [Unique Leads 1 Month],

     [Unique Permissions], Contacts,Total_Permission;

Not applicable
Author

Thanks!

Anonymous
Not applicable
Author

Try this ,


If(Market =' Italy', sum([Unique Leads 1 Month])/sum([Active Contacts]),'Na' ) as LeadsByActiveContacts