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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Date field issue wherein I need to select previous month.

Hi Everyone,

I have a field YearMonth which has values like 201507, 201506, 201505 ..201501.

I want to create an other field like PreviousYearMonth which should display 201506,201505,201504....201412 .ie previous month data for YearMomth.

I am facing issue to handle January month . Like if I select January , for eg 201501. It should give 201412.

Kindly help me with this issue.

Thanks in advance..

1 Solution

Accepted Solutions
Not applicable
Author

Hello Clever

It is working fine..!! Thanks

View solution in original post

9 Replies
Clever_Anjos
Employee
Employee

=date(addmonths(Date#('201501','YYYYMM'),-1),'YYYYMM')

jonathandienst
Partner - Champion III
Partner - Champion III

For this sort of analysis, I create a MonthIndex field in my master calendar:

     Year * 12 + Month As MonthIndex,

Now for the set analysis:

     =Sum({<MonthIndex = {"$(=Max(MonthIndex) - 1)"}>} Sales)

But you will probably be making selections on fields Year, Month. You will need to ignore these selections:

     =Sum({<MonthIndex = {"$(=Max(MonthIndex) - 1)"}, Year=, Month=>} Sales)

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

Thanks Clever Anjos and Jonathan Dienst .

I will try above solutions provided by you and gert back on this.

sujeetsingh
Master III
Master III

Format the dates as per your need and use inter-record function previous()

Not applicable
Author

Hello Clever

This seems to be particularly for the month of Jan, I need a generic expression which will take care for all other months including January.

However i will try to work on above expression.

Not applicable
Author

Hello Clever

It is working fine..!! Thanks

Clever_Anjos
Employee
Employee

Instead 201501 could be any month, it was just an example

=date(addmonths(Date#('201501','YYYYMM'),-1),'YYYYMM')

Not applicable
Author

Exactly!!

Not applicable
Author

Hello Chintan,

Hope this will help you out.

Main:

Load *,Date(AddMonths(Date#(Dates,'YYYYMM'),-1),'YYYYMM');

load * Inline [

Dates

201507,

201506,

201505

];


Thank you