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: 
afa24
Contributor II
Contributor II

How to code a max date in an expression

Hi

I have only just started using Qliksense and need some help.

This is my current expression;

=if(Year >= 2015 and Year < 2022,Year,NULL())

There is no data before 2016 hence why i hardcoded the 2015, but i dont want to hardcode the max year(and have to go in each year and update the max year) but i am unsure how to write the expression. 

If i dont specify a year it brings across data year types. Any help would be greatly appreciated

Thanks

 

1 Solution

Accepted Solutions
Sweta_Sharma
Former Employee
Former Employee

Hi @afa24 .
Year(Today()) can be used for current or max year.
Cheers!

If the issue is solved please mark the answer with Accept as Solution

View solution in original post

4 Replies
Sweta_Sharma
Former Employee
Former Employee

Hi @afa24 .
Year(Today()) can be used for current or max year.
Cheers!

If the issue is solved please mark the answer with Accept as Solution
anthonyj
Creator III
Creator III

Hi,

I would add that since you have no data before 2016 you won't need to add the ">=" part of the condition and instead of using an "If" condition in your dimension, use set analysis in your measure. This will result in the max year being taken from the max year in your data.

For example:

count({$<year={"<$(=max(year))"}>}Column)

Thanks

Anthony

afa24
Contributor II
Contributor II
Author

Thanks for that - i changed the bit of code to the following

=if(Year >= 2015 and Year <= year(today()),Year,NULL())

 

and it worked!

 

Thanks for the help

afa24
Contributor II
Contributor II
Author

Hi Anthony - ill need to do some further investigation on the set analysis in the measure - . Thank you for the reply and ill see what i can find with the set analysis