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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
bharatkishore
Creator III
Creator III

if else condition

I have the following code:

LOAD

     sum(U_NL9s) as U_NL9s,

     sum([U-D_NL9s]) as [U-D_NL9s],

     sum(D_NL9s) as D_NL9s,

     Calendar_Month_Code,

     Country,

     Batch_Code,

     sum(mat_con_qua) as mat_con_qua,

  if(Country='Brazil' and Batch_Code='U',

     (Sum(if(Strategic_Part='Tubes' and not IsNull([U-D_NL9s]) and [U-D_NL9s]<>0 and [U-D_NL9s]<>0.01, mat_con_qua))*-1)*(sum([U-D_NL9s])*1.055),

      (Sum(if(Strategic_Part <>'Tubes' and not IsNull([U-D_NL9s]) and [U-D_NL9s]<>0 and [U-D_NL9s]<>0.01, mat_con_qua))*-1)*(sum([U-D_NL9s])*1.200)) as test  

from [..\Consfiltered_NR.qvd]

(qvd)group by  Batch_Code, Country,Strategic_Part,Calendar_Month_Code;

    

My formula is working fine till

if(Country='Brazil' and Batch_Code='U',

     (Sum(if(Strategic_Part='Tubes' and not IsNull([U-D_NL9s]) and [U-D_NL9s]<>0 and [U-D_NL9s]<>0.01, mat_con_qua))*-1)*(sum([U-D_NL9s])*1.055)

but else condition is not giving me correct value. i.e

(Sum(if(Strategic_Part <>'Tubes' and not IsNull([U-D_NL9s]) and [U-D_NL9s]<>0 and [U-D_NL9s]<>0.01, mat_con_qua))*-1)*(sum([U-D_NL9s])*1.200))

Can you please tell me where i am doing wrong.

Thanks,

Bharat

Labels (1)
1 Reply
petter
Partner - Champion III
Partner - Champion III

You are referencing the mat_con_qua field that is calculated in the same LOAD statement which will not work. I think you should replace the mat_con_qua with Sum(mat_con_qua) in your If() statement and see how that works for you.