Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Shahzad_Ahsan
Creator III
Creator III

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
Vengatesh
Partner - Creator
Partner - Creator

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.

View solution in original post

5 Replies
Nuckpio
Contributor III
Contributor III

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

Shahzad_Ahsan
Creator III
Creator III
Author

"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
Vengatesh
Partner - Creator
Partner - Creator

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.
miskinmaz
Creator III
Creator III

Hi,
You can try with the below expression
above(Sum(Sales),2,1)
Shahzad_Ahsan
Creator III
Creator III
Author

Hi @Vengatesh 

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.