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: 
Not applicable

variable - Last Year returing current year

hi!

i currently have a dataset whereby i wish to show LY and CY values.

i  am struggling however with a variable that should look at the previous year same date. It returns exactly the same value as the current year.

any help is greatly appreciated.

vSetPreviousYearDay

{$<Date= {"=$(=Date(MakeDate(Max(Year) - 1, Max([Month (#)]), Day(Max(Date))),'YYYY-MM-DD'))"}
>}

=Sum($(vSetPreviousYearDay)Sales)

1 Solution

Accepted Solutions
maxgro
MVP
MVP

maybe with AddYears, variable in bold

sum(  {$<Date= {"=$(=Date(addyears(max(Date),-1),'YYYY-MM-DD'))"} >} Sales)

View solution in original post

3 Replies
maxgro
MVP
MVP

maybe with AddYears, variable in bold

sum(  {$<Date= {"=$(=Date(addyears(max(Date),-1),'YYYY-MM-DD'))"} >} Sales)

Not applicable
Author

Thank you for your reply,

if i were to choose two dates is there a possible variable that allows for that instead of a singular day?

example - 2015-09-01 and 2015-09-02

return sum of 2014-09-01 and 2014-09-02

maxgro
MVP
MVP

maybe a union

sum(

     {$

          <Date={"$(=Date(addyears(max(Date),-1),'DD/MM/YYYY'))"}>

          +

          <Date={"$(=Date(addyears(min(Date),-1),'DD/MM/YYYY'))"}>

     } Sales)