Skip to main content

New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
On-Demand Webinar: Learn proven best practices for a smooth transition to Qlik Sense® SaaS. REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
DS14
Partner - Contributor III
Partner - Contributor III

Getting Preevious Month Data in Current Month

Hi Experts,

I need to reuse the previous month value in current month. How I can achieve this please suggest.

For Example:

ClosingMonthend
Mar-18 No. of Emp640
Apr-18 No. of Emp641
May-18 No. of Emp638
Jun-18 No. of Emp640
Jul-18 No. of Emp675
Aug-18 No. of Emp681
Sep-18 No. of Emp679
Oct-18 No. of Emp678
Nov-18 No. of Emp677
Dec-18 No. of Emp679
Jan-19 No. of Emp698
Feb-19 No. of Emp699
Mar-19 No. of Emp698

 

I have the data for March'18 to March'19.

Now I need the output as below

OpeningMonthend
Mar-18 No. of Emp-
Apr-18 No. of Emp640
May-18 No. of Emp641
Jun-18 No. of Emp638
Jul-18 No. of Emp640
Aug-18 No. of Emp675
Sep-18 No. of Emp681
Oct-18 No. of Emp679
Nov-18 No. of Emp678
Dec-18 No. of Emp677
Jan-19 No. of Emp679
Feb-19 No. of Emp698
Mar-19 No. of Emp699
Apr-19 No. of Emp698

 

Please suggest how i can achieve this.

Thanks in advance.

 

Labels (2)
2 Replies
mcsshg2011
Contributor III
Contributor III

You can use expression Above(Sum(MonthEnd)) provided the sorting is the sequence you expected.

Vegar
MVP
MVP

If handling this in front end then @mcsshg2011 is probably the way to go, but if you are able to manipulate the script then you have two possible solutions. 

Manipulating the header by adding one month:

image.png

Data
LOAD Closing, Capitalize(Date(MonthName(date#(Subfield(Closing, ' ',1), 'MMM-YY') , 1), 'MMM-YY')) & ' No. of Emp' as Opening, Monthend FROM [https://community.qlik.com/t5/New-to-Qlik-Sense/Getting-Preevious-Month-Data-in-Current-Month/m-p/1571887#M133387] (html, codepage is 1252, embedded labels, table is @1);

Reading the previous loaded data:

By fetching the Monthly amount from the previous line read you are able to get the previous month value, but you wont get a value for 'Apr-19 No. of Emp' as it is not in your data. It is also important that you are able to sort your input data correctly, hence it is reading the previous line.

image.png