Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
bharatkishore
Creator III
Creator III

expression help

Hi all,

I have the following expression which i have given in script but the formula is not working at script level where if i take in text box i am geting correct value..

      if(Country='Brazil' ,

     ((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)*(([U-D_NL9s])*1.055),0)

Can you please help me why. with the formula what i write in script i am getting 46k but i should get 1.2K

Attached app for reference.

1 Solution

Accepted Solutions
sunny_talwar

[U-D_NL9s] repeats and using Sum([U-D_NL9s]) is causing the problem... if I use this expression in a chart with [U-D_NL9s] as dimension... I see the right number

=(Sum(mat_con_qua*-1)*[U-D_NL9s])*1.055

for text box object, you can try this

=Sum(Aggr((sum(mat_con_qua*-1)*[U-D_NL9s])*1.055, [U-D_NL9s]))

Capture.PNG

View solution in original post

18 Replies
isingh30
Specialist
Specialist

May be this -

if(Country='Brazil',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*(([U-D_NL9s]*1.055),0)

Thank you!

bharatkishore
Creator III
Creator III
Author

Sorry your expression is not working..May be did i miss any brace please let me know.

bharatkishore
Creator III
Creator III
Author

stalwar1‌ can you please help Sunny bhai..

sunny_talwar

[U-D_NL9s] repeats and using Sum([U-D_NL9s]) is causing the problem... if I use this expression in a chart with [U-D_NL9s] as dimension... I see the right number

=(Sum(mat_con_qua*-1)*[U-D_NL9s])*1.055

for text box object, you can try this

=Sum(Aggr((sum(mat_con_qua*-1)*[U-D_NL9s])*1.055, [U-D_NL9s]))

Capture.PNG

sunny_talwar

Or even this

=Sum(mat_con_qua*-1*[U-D_NL9s]*1.055)

bharatkishore
Creator III
Creator III
Author

Thank you sunny bhai for qucik response, but i need to derive this in script. The condition is

=if(Country='Brazil' ,

 

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

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

so in text box i am giving sum to test but else condition is not working or may be i am doing wrong

sunny_talwar

Not sure I understand? What is the right number and what aren't you getting? Comparing front end number to back end number is not a smart thing because script go through a lot of changes... what you should do is to figure out the number you are hoping to see based on database or based on talking to users or something to that end.

bharatkishore
Creator III
Creator III
Author

Sunny Bhai, hope i will explain clearly..

I had a formula where i should take country brazil and Strategic_Part should be tubes and [U-D_NL9s] should not be null and [U-D_NL9s] should not be 0 and [U-D_NL9s] should not be 0.01

if this is satisfied then we need to do mat_con_qua *-1*[U-D_NL9s]*1.055 .

to derive this i have used the following formula

  if(Country='Brazil' ,

    ((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)*(([U-D_NL9s])*1.055),0)

I am getting value as 478420 but when i take in a text box it is showing as 12098037.

So is 12098037 is wrong.. please correct me.

Attached app as well.

sunny_talwar

okay, so 12098037... what do you want to do? Fix the text box? fix the back end? I already gave you the reason about why text box is showing the wrong number....