Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Announcements
Talk to Experts, a LIVE Q&A Webinar. Bring your Qlik Sense Business questions on Aug. 4th. Register
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Not applicable

How to write a variable?

Hi,

I have a variable $'(vMonthENDDATE)'= date(monthend(today(),0),'YYYYMMDD') which returns the value of 20161130(Current Month End date)

What should be the expression  if I want to create a variable to return the value of 20161031?(Previous Month end date)

6 Replies
Highlighted
Specialist
Specialist

Re: How to write a variable?

Hi Badhikari,

The expression will be:

date(monthend(today(), -1),'YYYYMMDD')

Which is pretty similar to yours, the difference is the -1 instead of zero.

Arnaldo Sandoval
A journey of a thousand miles begins with a single step.
Highlighted
Creator II
Creator II

Re: How to write a variable?

use $1 instead of $...

Thanks,

Praveen Kumar S

Highlighted
MVP
MVP

Re: How to write a variable?

maybe

the previous month end of current month end date

is 1 day before current month start

=date(monthstart(today()) -1, 'YYYYMMDD')

Highlighted
Specialist
Specialist

Re: How to write a variable?

=Date(MonthStart(Today())-1,'YYYYMMDD')

Highlighted
Contributor III
Contributor III

Re: How to write a variable?

You can try something like this.

vPriorMonthENDDATE = Addmonths(vMonthENDDATE,-1)

Highlighted

Re: How to write a variable?

This will not work

For Example: 28th of February will return 28th of January which is not a month end. You would have to include MonthEnd formula again like:

vPriorMonthENDDATE = MonthEnd(Addmonths(vMonthENDDATE,-1))

I however would follow maxgro suggestion:

=date(monthstart(today()) -1, 'YYYYMMDD')



hth

cheers Lech, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful to the problem.