Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Qlik1_User1
Specialist
Specialist

To get Date between 1 - Jan to 31 Dec of current year only, to be used as DIM in expression

Hi All, 

Need to get Date between 1 Jan to 31 Dec of current year only and this to be used as DIM in expression.
without use of back-end script.

Except below expression

If(Date>=YearStart(today()) and Date<=YearEnd(today()),  Date)

3 Replies
sunny_talwar

Would you be able to provide more details as to what all have you already tried and what is the issue so far?

Qlik1_User1
Specialist
Specialist
Author

Hi @sunny_talwar 

I have tried below expression and its working fine.
If(Date>=YearStart(today()) and Date<=YearEnd(today()),  Date)

Issue is date field has last 10 year data and as per requirement 1 chart need to show current year data.
This needs to be done via expression but not from backend scripting.

shared expression is bit performance impacting that is causing an issue.

sunny_talwar

Create a flag for current year in the script

If(Year(Date) = Year(Today()), 1, 0) as CurrentYearFlag

and then use this in your expression

Sum({<CurrentYearFlag = {'1'}>}Measure)