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

How to find the Difference between the two filed Values?

Hi All,

I have The following Data and from that,How to find out the Difference Between the SOHOty for the two weeks?

WareHouseType               ProductCode         Week                        SOHQty

SQL                                   1234                    20150103                    285

SQL                                    1234                   20150110                    315

1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

Small correction in your code.

Please have a Look..... 

Temp: 

Load * Inline [ 

WareHouseType,ProductCode,Week,SOHQty 

SQL,1234,20150103,285 

SQL,1234,20150110,315 

SQL,1234,20150117,500 

SQL,123,20150103,285 

SQL,123,20150110,315 

SQL,123,20150117,500 ]; 

 

 

NoConcatenate 

Final: 

Load *,

If(WareHouseType = Previous(WareHouseType) And ProductCode = Previous(ProductCode), 

SOHQty - Previous(SOHQty),SOHQty) As Diff Resident Temp Order by WareHouseType,ProductCode,Week; 

 

 

Drop Table Temp;

Thank You...

View solution in original post

5 Replies
anbu1984
Master III
Master III

Temp:

Load * Inline [

WareHouseType,ProductCode,Week,SOHQty

SQL,1234,20150103,285

SQL,1234,20150110,315

SQL,1234,20150117,500

SQL,123,20150103,285

SQL,123,20150110,315

SQL,123,20150117,500 ];

NoConcatenate

Final:

Load *,If(WareHouseType = Previous(WareHouseType) And ProductCode = Previous(ProductCode),

SOHQty - Previous(SOHQty)) As Diff Resident Temp Order by WareHouseType,ProductCode,Week;

Drop Table Temp;

Anonymous
Not applicable
Author

Hi Anbu...

Thank you for the fast reply !!!

But for the First and fourth value in Diff filed getting Null values...But I need As same what is the value in SOHQty..

anbu1984
Master III
Master III

If(WareHouseType = Previous(WareHouseType) And ProductCode = Previous(ProductCode),

SOHQty - Previous(SOHQty),SOHQty)

Anonymous
Not applicable
Author

Small correction in your code.

Please have a Look..... 

Temp: 

Load * Inline [ 

WareHouseType,ProductCode,Week,SOHQty 

SQL,1234,20150103,285 

SQL,1234,20150110,315 

SQL,1234,20150117,500 

SQL,123,20150103,285 

SQL,123,20150110,315 

SQL,123,20150117,500 ]; 

 

 

NoConcatenate 

Final: 

Load *,

If(WareHouseType = Previous(WareHouseType) And ProductCode = Previous(ProductCode), 

SOHQty - Previous(SOHQty),SOHQty) As Diff Resident Temp Order by WareHouseType,ProductCode,Week; 

 

 

Drop Table Temp;

Thank You...

Anonymous
Not applicable
Author

Thank You Anbu...