Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Discover how organizations are unlocking new revenue streams: Watch here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to calculate Remaining QTY by dimension?

Hi, i have a table in QV:

ProductIDShopIDDateIDQTY
53110101.01.201320
53110102.01.2013-1
53110105.01.2013-2
53110202.01.201310
53110204.01.2013-5
53110107.01.2013-2
53110208.01.20133
53110108.01.2013-2
53110210.01.2013-1
53110211.01.2013-2

Need to calculate Remaining QTY by ShopID, DateID.

The resulting table should look like this:

ProductIDShopIDDateIDQTYRemainingQTY
53110101.01.20132020
53110102.01.2013-119
53110105.01.2013-217
53110202.01.20131010
53110204.01.2013-55
53110107.01.2013-215
53110208.01.201338
53110108.01.2013-213
53110210.01.2013-17
53110211.01.2013-25


6 Replies
Not applicable
Author

Hi,

The way you show your result is not that easy to achieve.

Maybe you would consider a more easy method.

For example see my attached file

Regards,

Gerrit

Not applicable
Author

Thank you!

But unfortunately i need to get a division remaining QTY by ShopID in the form of a graph.

I can calculate the RemainingQTY of the whole on all ShopID.

Example in the attachment.

  

Calculation formula in this case would be the following :

RemQTY = alt(Above([RemQTY]),SUM({<DateID={"<$(=MIN(DateID))"}>}TOTAL QTY)) + SUM(QTY)

udit_kumar_sana
Creator II
Creator II

Hi,

Pls Find the attached qvw for the solution.

Thanks & Regards,

Udit

udit_kumar_sana
Creator II
Creator II

hi ,

Pls find the attached qvw for the solution

Thanks & Regards,

Udit

udit_kumar_sana
Creator II
Creator II

For the line chart way pls find the attachment

tresesco
MVP
MVP

In the script, something like:

Load *,
If(ShopID=Peek('ShopID'), RangeSum(Peek('QTY'),QTY), QTY) As RemQTY;

load * Inline [
ProductID, ShopID, DateID, QTY
531, 101, 01.01.2013, 20
531, 101, 02.01.2013, -1
531, 101, 05.01.2013, -2
531, 102, 02.01.2013, 10
531, 102, 04.01.2013, -5
531, 101, 07.01.2013, -2
531, 102, 08.01.2013, 3
531, 101, 08.01.2013, -2
531, 102, 10.01.2013, -1
531, 102, 11.01.2013, -2
];  

Note: You might have to use ORDER BY clause based on your original data.

PFA