Qlik Community

QlikView Deployment

Discussion Board for collaboration related to QlikView Deployment.

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
MVP
MVP

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


Well, if you want back-end solution try:

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

9 Replies
Not applicable

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

Hi All

Enclosed my QV doc.

Paul

Not applicable

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

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

Not applicable

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

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!

MVP
MVP

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

Hi Paul,

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

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

Not applicable

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

Hi Shy

I try :-

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

I still get 0.

Any idea ?

Paul

Not applicable

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

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

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

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

MVP
MVP

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


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

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

Hi Tres

Thank you vey much it work fine now.

Paul