Qlik Community

Ask a Question

App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

Announcements
Join us for a live Q&A! September 21, 10 AM ET - Onboarding Fast in Qlik Sense SaaS! REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
aswinnar
Partner
Partner

Current Month Jan to Previous Month Dec

Hi All, 

I am having a requirement where I need to place values for current month vs previous month 

 

 

FIELD1Date (Year month format)
A202009
B202010
C202011
D202012
E202101


I have variable set for value in current month, however I am not able to create a proper expression for getting the values from the pervious Year Month. Mainly because of Jan to Dec. If I use 202101 as current Year Month for example, I am getting 202100 as Previous Year Month Date. What expression can I use for when current year month is 202101, the previous year month date will show as 202012? 

Labels (2)
2 Replies
Vegar
MVP
MVP

By the looks of it your date field is not a date, but an integer. Therfore you can not use date funtions like addmonth() on it without manipulating it a bit. Try something like this to get prev month. 

Num(Text(Date(Addmonths(date#([Date Field], 'YYYYMM'), - 1), 'YYYYMM'))) 

Plees ekskuse my Swenglish and or Norweglish spelling misstakes
bhavyagrb
Partner
Partner

Hello,

Hope this helps you!!

In Frontend  Expression:

=date(Addmonths(date#([Date(Year month format)], 'YYYYMM'), - 1),'YYYYMM')

 

Regards,

Bhavya