Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
nancymarmat
Contributor II
Contributor II

Single date selection - date and same day last year

I have 3 date selection boxes: Year, Month and Mfg Date.  They are all based on a single field, MfgDate.

My pivot table contains data for Current Year and Prior Year.

            sum({$< Year={$(=Only(Year))}>} Yards)

sum({$< Year={$(=Only(Year)-1)}>} Yards)

This works when I select Year and Month. However when I select an individual day in the Mfg Date selection box, I lose the data for Prior Year.

How can I override the year and month if I have made a selection for Mfg Date?

When I make a selection in Mfg Date, I would like the selected date plus the same day last year automatically. It will display both dates if I select them both from the list.  Is it possible in Qlikview to make one date selection and in the expression use the same day for the prior year?

Thank you for any ideas.

3 Replies
settu_periasamy
Master III
Master III

May be try like this..

=sum({$< Year={"$(=Year(Addyears(MfgDate,-1)))"},Month>} Yards)

nancymarmat
Contributor II
Contributor II
Author

It did not return the desired results.

It did point me in the right direction...=sum({$< Year={"$(=Year(Addyears(MfgDate,-1)))"},MfgDate>} Yards)

returns data for the entire month of the prior year., but the Year and Month selectors no longer work.

How do I use Addyears only if there is a selection in the MfgDate selection list?

nancymarmat
Contributor II
Contributor II
Author

I used this workaround - I added the Day field to the script and changed the MfgDate selection to Day selection.  When the three selections, Year, Month and Day are used together the existing expressions work perfectly.

Thank you for your suggestions.  I learned about a new function Addyears which will be very helpful in the future.