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
Contributor
Contributor

Calculate two year gap

Hello All

Please help me in the below query. I want to create a variable which calculates two year gap from today’s date.

I have created as below:

DATE(IF(ROUND(YEAREND(TODAY())-YearStart(TODAY()))= 365, MONTHSTART(TODAY())-730, MONTHSTART(TODAY())-731))

The issue in that code is when the New Year starts i.e. 2017. The above formula fails as the difference between the year end data & year start date for 2017 is 365. Thus if I use above formula it will subtract 730 days.

01-01-2017 – 730 = 02-01-2015

But I want 01-01-2015.

Please help me to rectify my mistake

Thanks

DC

1 Solution

Accepted Solutions
Highlighted
MVP
MVP

As far as I understand,

Monthstart(Today(), -24)

should return the correct result.

View solution in original post

4 Replies
Highlighted
MVP
MVP

I don't really get what you want to calculate, do you just need the yearstart date two years ago?

=Yearstart(Today() ,-2)

or the monthstart two years ago?

=Monthstart(Today() ,-24)

or today's date two year's ago?

=AddYears(Today() ,-2)

Highlighted
Contributor
Contributor

Thanks Sir..

I want to go the start day of the month two year back from today's date with no impact of Leap year.

I think Monthstart(today(),-24) will work

Please guide

Highlighted
MVP
MVP

As far as I understand,

Monthstart(Today(), -24)

should return the correct result.

View solution in original post

Highlighted
Contributor
Contributor

Thanks sir!!