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: 
janvandernagel
Contributor III
Contributor III

Date comparisson in set modifier

Hello

I'm trying to count the record with a date smaller then today.

With a hard coded date it is working:
=Count ({$ < NextDate={"<05-02-2020"}>} Maintenance)

I've tried to replace the date with the function Today(), that did not work.

So I've made a variable (Let varToday = floor(Today()); ) and want to use this variable:

=Count ({$ < NextDate={'<=$(varToday)'}>} Maintenance)

What am I doing wrong?

Thanks in advance

Jan

1 Solution

Accepted Solutions
janvandernagel
Contributor III
Contributor III
Author

Thanks for putting me in the right direction. The date format was indeed the problem.
I've been puzzling for quite a while with this article (and your input):

https://community.qlik.com/t5/Qlik-Design-Blog/Dates-in-Set-Analysis/ba-p/1472511

Based on that I set a variable in the script:

Set vTodayTxt = "=Date(Today(),'DD-MM-YYYY')";

And I used that variable in the expression:

=Count ({$ <NextDate ={"<$(vTodayTxt)"}>} Maintenance)

View solution in original post

3 Replies
Vegar
MVP
MVP

It's hard to be sure about your issues, it depends on your system date format, but I'll try to guide you in the right direction. 

1. When you want to evaluate a modifier you should use " " not ' '. 

2. All single value set modifier evaluations are text based, your expression should return a string value.

{<Date = {'42769'}>}  will not work if your Date is formatted as a dual with a text representation like this '2020-02-03' or similar. You will need to generate {<Date = {'2020-02-03'}>} .

janvandernagel
Contributor III
Contributor III
Author

Thanks for putting me in the right direction. The date format was indeed the problem.
I've been puzzling for quite a while with this article (and your input):

https://community.qlik.com/t5/Qlik-Design-Blog/Dates-in-Set-Analysis/ba-p/1472511

Based on that I set a variable in the script:

Set vTodayTxt = "=Date(Today(),'DD-MM-YYYY')";

And I used that variable in the expression:

=Count ({$ <NextDate ={"<$(vTodayTxt)"}>} Maintenance)

Vegar
MVP
MVP

Glad it worked out for you!