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

Announcements
ALERT: QlikView server communication interruptions following Microsoft Windows Domain Controller security updates
cancel
Showing results for 
Search instead for 
Did you mean: 
soha1902
Creator
Creator

Previous

Hi All,

I have following Data:

Load * Inline [
Date,Sales
12/12/2014,50
01/01/2015,100
01/02/2015,200
01/03/2015,300
01/04/2015,500
01/05/2015,600 ]
;

Tab1:
Load
Date as Date,
Sales as Sales,
Previous(Previous(Sales)) as PreSales
Resident Tab;
Drop Table Tab;

As of now in "Presales" column I am getting values of last 2 days but in future this value will be change for last 5 or some other number.

So please let me the dynamic way which I can use in place of previous.

Labels (1)
17 Replies
soha1902
Creator
Creator
Author

it gives only sum of previus(Sales) + First value of sales. but I want sum of previous, plus all the record till first record.

sunny_talwar

This?

Capture.PNG

Tab:

Load * Inline [

Date, Sales

12/12/2014, 50

01/01/2015, 100

01/02/2015, 200

01/03/2015, 300

01/04/2015, 500

01/05/2015, 600

];

Tab1:

Load Date,

  Sales,

  RangeSum(Peek(Sales, -1), Peek(Sales, -2), Peek(Sales, -3)) as PreSales

Resident Tab;

Drop Table Tab;

SreeniJD
Specialist
Specialist

Hi There,

are you looking something like...

RangeSum(Previous(Sales),Peek(Sales)) as PreSales..

which will give you 1000 if you select 01/05/2015..

Happy to help

Sreeni

Digvijay_Singh

Something like this -

Tab1:

Load

Date as Date,

Sales as Sales,

RangeSum(Sales,Peek('PrevSales',-1)) as PrevSales

Resident Tab;

Drop Table Tab;

Anonymous
Not applicable

hi soha

Please see below post:

Peek() or Previous() ?

SreeniJD
Specialist
Specialist

Soha -

Are you looking for the desired results as mentioned in below tables (1st refers to presales by year, second one is across years)... Please clarify.

   

DateSalesPreSales
12/12/2014500
01/01/20151000
01/02/2015200100
01/03/2015300300
01/04/2015500600
01/05/20156001100

Date

SalesPreSales
12/12/2014500
01/01/201510050
01/02/2015200150
01/03/2015300350
01/04/2015500650
01/05/20156001150

Sreeni

soha1902
Creator
Creator
Author

This is correct sunny. I am looking the same but suppose I want to add last 30 days then I need to write 30 Peek(). How I will do the same in dynamically.

Thanks.

sunny_talwar

For dynamic solution, you might have to use Loop. I don't think there is an easier solution.

Best,

Sunny