Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
LEGION
Contributor II
Contributor II

How to Calculate Sum Value of Negative Stock in Qlik Sense

Hello, in my Stock data I have many lines with an ONHAND value that is negative (IE: -100,-50....).

I would like to sum up the value of these items by multiplying it by the cost of each stock line.

However the formula does not seem to work, I'm not sure what I'm doing wrong.

 

Formula I'm using:         IF( [ONHAND]<0, (sum( [ONHAND] * [COST] )) ,0 )

Labels (2)
2 Solutions

Accepted Solutions
vikasmahajan

Hi,

Create a field in the load script  like   [ONHAND] * [COST]  as VALUE

apply the following expression in the chart

sum ( {<VALUE = {'<0'}>} VALUE)

 

Regards

Vikas

Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.
If you want to go quickly, go alone. If you want to go far, go together.

View solution in original post

LEGION
Contributor II
Contributor II
Author

I cam right with a slight edit to the formula,

=sum({< [STOCKHOLDING] ={"<=0"}>} [STOCKHOLDING] )

View solution in original post

4 Replies
vikasmahajan

Hi,

Create a field in the load script  like   [ONHAND] * [COST]  as VALUE

apply the following expression in the chart

sum ( {<VALUE = {'<0'}>} VALUE)

 

Regards

Vikas

Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.
If you want to go quickly, go alone. If you want to go far, go together.
LEGION
Contributor II
Contributor II
Author

Hello,

I have done as suggested and created a field called STOCKHOLDING and did my formula as belo, but unfortunately the result is 0, when it should be -1.5M

 

(sum({<[STOCKHOLDING]={'<0'}>} STOCKHOLDING)

 

vikasmahajan

Can you post some sample data what you are using ?

Vikas

Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.
If you want to go quickly, go alone. If you want to go far, go together.
LEGION
Contributor II
Contributor II
Author

I cam right with a slight edit to the formula,

=sum({< [STOCKHOLDING] ={"<=0"}>} [STOCKHOLDING] )