# New to Qlik Sense

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

Announcements
Qlik Cloud Maintenance is scheduled between March 27-30. Visit Qlik Cloud Status page for more details.
cancel
Showing results for
Did you mean:
Contributor III

## Certain Periods from current year plus all of last 3 years

Hello beautiful people,

I apologize in advance if this has been solved in a previous post. I was not able to find it.

So what I need ist an expression that allows me to mark all periods(YearMonth) of the actual year - with a delay of 1.5  months as well as all periods of past 3 years.

If you it is e.g.  the 15th or > of August the goal is to display all periods up to 202206 of the current year as well as all periods of the last 3 years.

What I've got thus far is a marker for all periods equal with a delay of 1.5 months:

if(day(today())>15 and month(today())=1,

and another marker for the last 3 years (including current year)

=[YEAR]>year(today())-4

How to combine the two I haven't figured out yet.

Since I might need it for NPrinting, so no scripting or set expressions.

If someone could lead me into the right direction, I would be thankful.

Kind regards

Stefan

Labels (3)

• ### General Question

1 Solution

Accepted Solutions
Contributor III
Author

Hi Edwin,

Thanks for your reply. I want to give the internal customer as much freedom as possible and a marker is what they wanted, so I couldn't use set analysis.

I managed to convert the formula above to do just that:

Greater than the 15th of the month -> previous period actual year plus going back three full years.

Lower than the 15th of the month -> preprevious period actual year plus going back three full years:

=if(day(today())>15 and month(today())>1 and [YEAR] >= year(today())-3,
if(day(today()) >15 and month(today())=1 and [YEAR] >= year(today())-3,
if(day(today()) <15 and month(today())>1 and [YEAR] >= year(today())-3,
if(day(today()) <15 and month(today())=1 and [YEAR] >= year(today())-3,

Thanks for the link. I can use variables in other contexts so cheers

Kind regards

Stefan

2 Replies
Master

this is a common design pattern.  my suggested solution is to compute for the date boundaries dynamically, store them in variables and use the variables in your set analysis, it makes the expression readable.

https://community.qlik.com/t5/New-to-Qlik-Sense/how-to-calculate-previous-year-sales-till-current-ye...

Contributor III
Author

Hi Edwin,

Thanks for your reply. I want to give the internal customer as much freedom as possible and a marker is what they wanted, so I couldn't use set analysis.

I managed to convert the formula above to do just that:

Greater than the 15th of the month -> previous period actual year plus going back three full years.

Lower than the 15th of the month -> preprevious period actual year plus going back three full years:

=if(day(today())>15 and month(today())>1 and [YEAR] >= year(today())-3,
if(day(today()) >15 and month(today())=1 and [YEAR] >= year(today())-3,
if(day(today()) <15 and month(today())>1 and [YEAR] >= year(today())-3,