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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
AJ2024
Contributor II
Contributor II

Using Year Function in Set Analysis

Looking for help on syntax to use the Year function in set analysis. How do I need to modify the expression below to make it work?

=Sum({$<Year([Date Field])={2020}>}[Measure])

Labels (1)
1 Solution

Accepted Solutions
p_verkooijen
Partner - Specialist II
Partner - Specialist II

Hi @AJ2024 ,

Do you have a Year field based on the date in your datamodel? 

Then use

  • =Sum({$< Year={2020} >}[Measure])

Based on a date DD-MM-YYYY you could use

  • =Sum({$< [Date Field]={"*-2020"} >}[Measure])
It's better to create a Year field
  • Year([Date Field]) AS Year

 

Make it dynamic, select the max value of YEAR 

  • =Sum({$< Year={"=$(=MAX(Year))"} >}[Measure])

Last Year

  • =Sum({$< Year={"=$(=MAX(Year)-1)"} >}[Measure])
 

 

View solution in original post

2 Replies
p_verkooijen
Partner - Specialist II
Partner - Specialist II

Hi @AJ2024 ,

Do you have a Year field based on the date in your datamodel? 

Then use

  • =Sum({$< Year={2020} >}[Measure])

Based on a date DD-MM-YYYY you could use

  • =Sum({$< [Date Field]={"*-2020"} >}[Measure])
It's better to create a Year field
  • Year([Date Field]) AS Year

 

Make it dynamic, select the max value of YEAR 

  • =Sum({$< Year={"=$(=MAX(Year))"} >}[Measure])

Last Year

  • =Sum({$< Year={"=$(=MAX(Year)-1)"} >}[Measure])
 

 

AJ2024
Contributor II
Contributor II
Author

@p_verkooijen,

I don't have a year field in the data model currently but that sounds like the better solution. I'll go ahead and add it. Thanks!