Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to make Discount=0 change to Discount=1 ?

Hi All

I have a Field Discount in my Table

When i select BRNAD_P = HAKKO or MITSUBISHI Discount = 0

May i know how to make it = 1 ? ( Because List Price * Discount = Net Price , If Discount = 0 , Net price will be zero )

left join    (PRICE)

   

Load PART_NO_,

    'USD '& LIST_PRICE as PRICE_LIST,

  1-Discount as Discount_

Resident PRICE;

My Question is how to add some more script to below code , so that when it see 0 it will replace with 1 :-

  1-Discount as Discount_

1 Solution

Accepted Solutions
tresesco
MVP
MVP


Well, if you want back-end solution try:

If(Isnull(Discount) or Len(Trim(Discount))=0 or Discount=0, 1, Discount) as _Discount

View solution in original post

9 Replies
Not applicable
Author

Hi All

Enclosed my QV doc.

Paul

Not applicable
Author

For get to mentioned for testing you need to create a folder at C:\GE

Not applicable
Author

Hi Paul,

You can add a condition statement in your code as :

If(Discount_ = 0,1,Discount_) as Discount

and then use this field Discount in place of Discount_

Hope this helps!

tresesco
MVP
MVP

Hi Paul,

At the front-end you can use this formula for discount:

If(SUM(Discount)=0,1,Sum(Discount))

Not applicable
Author

Hi Shy

I try :-

If(Discount = 0,1,Discount) as Discount_

I still get 0.

Any idea ?

Paul

Not applicable
Author

Hi Tres

when i try your script :-

If(SUM(Discount)=0,1,Sum(Discount)) as Discount2,

I get error msg. expression error. may be i misunderstand your suggestion.

Paul

Not applicable
Author

Hi Tres

Now i understand what you mean , it work when i use your script at expression.

But for my application , i intend to make use of load script to cal the net price. any idea how to make load script work ?

Paul

tresesco
MVP
MVP


Well, if you want back-end solution try:

If(Isnull(Discount) or Len(Trim(Discount))=0 or Discount=0, 1, Discount) as _Discount

Not applicable
Author

Hi Tres

Thank you vey much it work fine now.

Paul