Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Shahzad_Ahsan
Contributor II

How to get two previous month record

Hi 

I have a table like this

Month-YearAmount
Jan-18968
Feb-18987
Mar-18456
Apr-18321
May-18369
Jun-18258
Jul-18987
Aug-18785
Sep-18478
Oct-18858
Nov-18741
Dec-182365
Jan-19847
Feb-1928
Mar-1998
Apr-19258

 

I need the result like this 

Month-YearAmountExpected
Jan-189680
Feb-189870
Mar-18456968
Apr-18321987
May-18369456
Jun-18258321
Jul-18987369
Aug-18785258
Sep-18478987
Oct-18858785
Nov-18741478
Dec-182365858
Jan-19847741
Feb-19282365
Mar-1998847
Apr-1925828

 

Please do it in script

Labels (1)
1 Solution

Accepted Solutions
Partner
Partner

Re: How to get two previous month record

Try This,

Load Month-Year,

Amount, 

Previous(Previous(Amount)) as Expected 

From Source

I have attached QV file, It should work fine in qs too

You Know What To Do.
5 Replies
Nuckpio
New Contributor III

Re: How to get two previous month record

I don't understand your problem... what do you want in your "expected" column ? 

Shahzad_Ahsan
Contributor II

Re: How to get two previous month record

"Expected" column is showing previous 2 months Amount
eg: Amount of Jan-18 is 968 and 968 in Expected column is showing in Mar-18
This is what I needed
Partner
Partner

Re: How to get two previous month record

Try This,

Load Month-Year,

Amount, 

Previous(Previous(Amount)) as Expected 

From Source

I have attached QV file, It should work fine in qs too

You Know What To Do.
Highlighted
miskinmaz
Contributor II

Re: How to get two previous month record

Hi,
You can try with the below expression
above(Sum(Sales),2,1)
Shahzad_Ahsan
Contributor II

Re: How to get two previous month record

Hi @tcv 

Thanks for the answer. This is working fine

I was using Previous function, but this works for previous only. I was looking for parameters in Previous then also not working. But you used nested previous and that worked.

Thanks a lot.