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

Announcements
January 14th - Discover the Trends Shaping AI in 2026: Register Here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Inventory difference

Could anyone help with this, supposedly, easy exercise? I've got an sql table containing inventory values at certain points of time e.g.:

Date, Value

2009-01-01, 10

2009-06-30, 9

2009-12-31, 12

2010-01-01, 7

and would like to find difference between the last and the first within a period to get:

-1 for 01-06.2009

2 for 01-12.2009

0 for 01-12.2010 (one record is the first and the last at the same time)

Due to the complexity of the rest of the script I need to set it within sql code.

Thanks, Przemek



1 Solution

Accepted Solutions
gajapathy74
Creator II
Creator II

Hi,

If my understanding is correct, the following load script will fulfill your need.

LOAD
date,
value,
(value - Previous(value)) as diff;
SQL SELECT
date,
value
FROM
sqlTable;

This will load each data from your sql table along with difference from your last record.

Regards,

View solution in original post

1 Reply
gajapathy74
Creator II
Creator II

Hi,

If my understanding is correct, the following load script will fulfill your need.

LOAD
date,
value,
(value - Previous(value)) as diff;
SQL SELECT
date,
value
FROM
sqlTable;

This will load each data from your sql table along with difference from your last record.

Regards,