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

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
prma7799
Master III
Master III

Write a conditional expression

Hi All,

I have fields called customer_code and sales_group and I have Sum(Grosssale) and Sum(netSale).

So I want to write an expression that if sale_group = ‘Gen’ , ‘Inst’, ‘imp’ and customer_code which start with ‘NP*’

then I want Sum(Grosssale) otherwise I want Sum(netSale).

Thanks

16 Replies
tamilarasu
Champion
Champion

Hi,

Try expression as,

If(Match(sale_group, ‘Gen’,‘Inst’,‘imp’ ) and WildMatch(customer_code,‘NP*’), Sum(Grosssale), Sum(netSale))

Anonymous
Not applicable

may be this?

=if(Sales_Group='Gen' or Sales_Group='Inst' or Sales_Group='Imp' and  Customer_Code like 'NP*',

Sum(GrossSales), Sum(NetSale))

prma7799
Master III
Master III
Author

Hi Tamil,

Thanks for response.

Your expression getting write output in straight or pivot table when one or more  dimension with customer_code  but when I removed customer_code from dimension then the output is not giving Sum(Grosssale) its giving Sum(NetSale)

Thanks

MayilVahanan

Hi

Try like this

In Script,

If(Match(sale_group, ‘Gen’,‘Inst’,‘imp’ ) and WildMatch(customer_code,‘NP*’), GrossSales, NetSale) AS Sales


Then in your expression, simply use Sum(Sales)

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
sasikanth
Master
Master

try this

Sum(if(match(sale_group, ‘Gen’,‘Inst’,‘imp’ ) and wildmatch(customer_code,''NP*'),Grosssale,netSale)

tamilarasu
Champion
Champion

In that case,

If(Sum({<sale_group={'Gen','Inst','imp'},customer_code={'NP*'}>}Grosssale)=0,

           Sum(netSale),

           Sum({<sale_group={'Gen','Inst','imp'},customer_code={'NP*'}>}Grosssale))

jagan
Partner - Champion III
Partner - Champion III

Hi,

Try like this

If(MixMatch(sale_group, ‘Gen’ , ‘Inst’, ‘imp’) AND customer_code LIKE ‘NP*’, Sum(Grosssale), Sum(netSale))

Hope this helps you.

Regards,

Jagan.

Anonymous
Not applicable

sum({<Sales Group='Gen'>} Gross sales)

write the expression in this way want you want the values required in column

Anonymous
Not applicable

Did you try what I suggested you?

You can replace And operator with OR for same