Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
martin_caruso
Contributor III
Contributor III

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?

I already appreciate your time and contributions.

Regards,


Martin.

1 Solution

Accepted Solutions
sunny_talwar

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)

View solution in original post

6 Replies
sunny_talwar

What is the expression for the other three?

martin_caruso
Contributor III
Contributor III
Author

  • 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)


sunny_talwar

May be try this

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

martin_caruso
Contributor III
Contributor III
Author

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


Capture.PNG

sunny_talwar

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)

martin_caruso
Contributor III
Contributor III
Author

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