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: 
brijesh1991
Partner - Specialist
Partner - Specialist

multiply a field by -1 at script level in qlikview

Hi All,

I had a problem in multiplying a field value by -1 at script level, look at my script, it's not working.

Example:

My data in backend is like this:

ID Amount

1 -800

2 700

3 -900

4 1000

5 -400

Whenever I am fetching data from backend and storing it into qvd,

In QVD, Amount  should multiply by -1

My script is:

Table1:

Load

ID,

(Amount*(-1)) as Amount

From SchemaName.TableName;

Store Table1 into [../Data/Qvd/Table1.Qvd](qvd);

In QVD, Data should be like this:

ID Amount

1 800

2 -700

3 900

4 -1000

5 400

Your feedback is precious to me. . .

Brijesh

1 Solution

Accepted Solutions
brijesh1991
Partner - Specialist
Partner - Specialist
Author

Hi er.mohit,

if(Amount>0,Amount*-1, Amount*-1) as Amount <--- it will make positive to negative and negative to positive. . . I have tried this, but why I can't do in this way--> Load ID, -1*Amount as Amount from........??

Thanks

View solution in original post

9 Replies
tresesco
MVP
MVP

Change the name of your newly created Amount field name:

Like:

Load

Amount*(-1) as NewAmount

Sokkorn
Master
Master

Hi Brijesh,

Your script should work. Can you post error load msg and full script here?

Regards,

Sokkorn

brijesh1991
Partner - Specialist
Partner - Specialist
Author

Thanks Sokkorn Cheav (Cambodia) for your efforts. . .

There is no error, just I am getting the same data as it was without multiplying by -1 even though we are applying the operator there. . .

Sokkorn
Master
Master

Hi Brijesh,

Let try this one

Table1:

Load

ID,

Num(Amount)*-1 as Amount

From SchemaName.TableName;

Let me know the result.

Regards,

Sokkorn

brijesh1991
Partner - Specialist
Partner - Specialist
Author

Thanks for your time, tresesco ...

it's working while we are using this in INLINE, but when we are fetching data from backend i.e we are using it with select or load statement, it's not working. . .

tresesco
MVP
MVP

Can you share your sample application?

er_mohit
Master II
Master II

have you tried this

if(Amount>0,Amount*-1) as Amount

brijesh1991
Partner - Specialist
Partner - Specialist
Author

Hi er.mohit,

if(Amount>0,Amount*-1, Amount*-1) as Amount <--- it will make positive to negative and negative to positive. . . I have tried this, but why I can't do in this way--> Load ID, -1*Amount as Amount from........??

Thanks

tresesco
MVP
MVP

Brijesh,

PFA. it works even with LOAD. may be there is something wrong in your app. if you can share,,,,,,can be checked.