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
prma7799
Master III
Master III
Author

Hi All,

I tried all expression which is given by you but not getting exact output.

Thanks

sasikanth
Master
Master

Please share your sample data if you can

tamilarasu
Champion
Champion

Yes. Please share sample file with expected output.

PradeepReddy
Specialist II
Specialist II

try like this..

Script:

If(match(sale_group, ‘Gen’ , ‘Inst’, ‘imp’) and wildmatch(customer_code,‘NP*’),'G','N') as Flag

Chart:

Expression 1: Sum({<Flag={'G'}>}Grosssale)

Expression 2: Sum({<Flag={'N'}>}netSale)

Expression 3: Sum({<Flag={'G'}>}Grosssale)+Sum({<Flag={'N'}>}netSale)

(Compare the 3rd expression result with the other 2 expressions)...


If still not getting, share the application...

Anonymous
Not applicable

SUM({<Sale_Group={'Gen'}>}GrossSale)

kaushiknsolanki
Partner Ambassador/MVP
Partner Ambassador/MVP

Try this.

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

Regards,

Kaushik Solanki

Please remember to hit the 'Like' button and for helpful answers and resolutions, click on the 'Accept As Solution' button. Cheers!
sfatoux72
Partner - Specialist
Partner - Specialist

Ok,

You wrote :

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 givingSum(Grosssale) its giving Sum(NetSale)

What need to happen if customer_code first 2 characters or sale_group is not unique in your filtered set of data?

If a part of your data correspond to your condition to use Sum(Grosssale) and other part to Sum(NetSale).