Skip to main content
Announcements
Jan 15, Trends 2025! Get expert guidance to thrive post-AI with After AI: REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
bharatkishore
Creator III
Creator III

if condition

Hi All,

I am writing the below expression in script.. but my expression is not working..Can you please tell me where i am missing out..

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

if(Strategic_Part='Tubes' and [U-D_NL9s]<>0 ,sum(mat_con_qua)*(-1)*sum([U-D_NL9s])*1.055,0)) as test

Thanks,

Bharat

1 Solution

Accepted Solutions
vishsaggi
Champion III
Champion III

Try this

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

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

View solution in original post

24 Replies
olivierrobin
Specialist III
Specialist III

hello

what does not working mean ?

error ?

wrong result ?

YoussefBelloum
Champion
Champion

Hi,

did you add a GROUP BY at the end of the LOAD ?

bharatkishore
Creator III
Creator III
Author

I am getting as invalid expression

bharatkishore
Creator III
Creator III
Author

Yes i have added group by..

m_perreault
Creator III
Creator III

Take -1 out of parenthesis

bharatkishore
Creator III
Creator III
Author

Please find my code so that it will be easy for you.

bharatkishore
Creator III
Creator III
Author

Hi,

Tried by removing -1 but still same error

YoussefBelloum
Champion
Champion

what are you trying to calculate using this:

sum(mat_con_qua)*(-1)*sum([U-D_NL9s])*1.055


why multiplying by -1 and 1.055 ?

olivierrobin
Specialist III
Specialist III

in you are in a load and want to do a sum, I would write

sum(

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

if(Strategic_Part='Tubes' and [U-D_NL9s]<>0 ,mat_con_qua)*(-1)*U-D_NL9s])*1.055,0)) as test

because with you syntax, you mix row level treatement (the if clause) and group treatmenet (sum)