# New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

New Contributor II

## Day to the previous year in set analysis

Hello, good afternoon!

I'm having problems with a KPI.

I have three selectors: year, month and day. The selectors of the year and month, by default, have a fixed fixed value. On the other hand, the day one does not.

I need to create four indicators, for example if I select year = '2017', month = 'dec' and day = '04/12/2017'. I have to show:

• sales to dec 2017
• sales to dec 2016
• sales at 04/12/2017
• sales at 04/12/2016

The first three, I could calculate without any problem. On the other hand, for the last one, sales to the day of the previous year, I could not. I tried in the set analysis with year-1 and day-365, but I get 0. The strange thing is that in the label, using this function: Date (DIM_DATE - 365), the KPI tells me the correct date , that is, 04/12/2016.

Any solution that comes to mind?

Regards,

Martin.

1 Solution

Accepted Solutions
MVP

## Re: Day to the previous year in set analysis

Forgot that you are selecting year... try this

Count({<CONDICION_FINAL = {'A'}, DATE_ACL = {"\$(=Date(AddYears(Max(DATE_ACL), -1), 'DD/MM/YYYY'))"}, YEAR_DATE>} DISTINCT EMPLID)

6 Replies
MVP

## Re: Day to the previous year in set analysis

What is the expression for the other three?

New Contributor II

## Re: Day to the previous year in set analysis

• dec 2017

Count({<CONDICION_FINAL = {'A'}, FLAG_MONTH_END = {1}, DATE_ACL=>} DISTINCT EMPLID)

• dec 2016

Count({<CONDICION_FINAL = {'A'}, FLAG_MONTH_END = {1}, YEAR_DATE={\$(=max(YEAR_DATE)-1)}, DATE_ACL=>} DISTINCT EMPLID)

• 04/12/2017

Count({<CONDICION_FINAL = {'A'}>} DISTINCT EMPLID)

MVP

## Re: Day to the previous year in set analysis

May be try this

Count({<CONDICION_FINAL = {'A'}, DATE_ACL = {"\$(=Date(AddYears(Max(DATE_ACL), -1), 'DD/MM/YYYY'))"}>} DISTINCT EMPLID)

New Contributor II

## Re: Day to the previous year in set analysis

I pass the capture of the filters that I have selected. Apply the expression you passed to me and keep giving me 0.

MVP

## Re: Day to the previous year in set analysis

Forgot that you are selecting year... try this

Count({<CONDICION_FINAL = {'A'}, DATE_ACL = {"\$(=Date(AddYears(Max(DATE_ACL), -1), 'DD/MM/YYYY'))"}, YEAR_DATE>} DISTINCT EMPLID)

New Contributor II

## Re: Day to the previous year in set analysis

Great as always, stalwar1! Thank you very much for your help