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

Announcements
Register by January 31 for $300 off your Qlik Connect pass: Register Now!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Comparing date in set-analysis doesn't work

I have no clue why this work:

= if ([Unavailable Start Date] < $(vEndDate4), 'true', 'false')

And this also:

( {$< [WorkItem
Enddate]
= {">=$(vBeginDate4)<=$(vEndDate4)"}
>} [WorkType Todo] )

 

But this doesn't:

count( {$< [Unavailable Start Date] = {">=$(vBeginDate4)<=$(vEndDate4)"} >} [Unavailable
Start Date]
)

1 Solution

Accepted Solutions
jagan
Partner - Champion III
Partner - Champion III

Hi,

try this

=count( {$< [Unavailable Start Date] = {">=$(=Date(vBeginDate4))<=$(=Date(vEndDate4))"} >} [Unavailable Start Date] )


If not working check whether the date format in variables and dimension are same.


Regards,

Jagan.

View solution in original post

6 Replies
jagan
Partner - Champion III
Partner - Champion III

Hi,

try this

count( {$< [Unavailable Start Date] = {">=$(=vBeginDate4)<=$(=vEndDate4)"} >} [Unavailable Start Date] )


If not working check whether the date format in variables and dimension are same.


Regards,

Jagan.

Not applicable
Author


It doesn't work.

How do I check? Because doesn't this depens on the formatting of listbox?

When i put no formatting on the listboxes their appearence is not the same.

[Unavailable Start Date] -> displays as a date

vBeginDate4 -> as a number

Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

Gerry - you got it! The problem is caused by the fact that the two values are formatted differently, and it's important in Set Analysis.

So, for example:

if ([Unavailable Start Date] < $(vEndDate4), 'true', 'false') works because QlikView evaluates the expression, using the numeric value of the date field, and comparing it to the numeric value of the variable.


count( {$< [Unavailable Start Date] = {">=$(vBeginDate4)<=$(vEndDate4)"} >} [Unavailable
Start Date]
) - doesn't work, because  the field is formatted as a date, and the variables are formatted as numbers, and that's an incorrect syntax in Set Analysis.


I'd suggest one of the two following solutions:


1. Format the variables as Dates:

count( {$< [Unavailable Start Date] = {">='$(=date(vBeginDate4))'<='$(date(vEndDate4))'"} >} [Unavailable
Start Date]
)


2. Re-work the condition into a Boolean condition that can compare the field with the variable numerically:


count( {$< [Unavailable Start Date] = {"=(num([Unavailable Start Date])>=$(vBeginDate4) and num([Unavailable Start Date])<=$(vEndDate4))"} >} [Unavailable Start Date] )


can't guarantee the syntax 100%, I only typed it here with no validation...


best,


Oleg Troyansky

www.masterssummit.com

www.naturalsynergies.com


Ask me about Qlik Sense Expert Class!
jagan
Partner - Champion III
Partner - Champion III

Hi,

try this

=count( {$< [Unavailable Start Date] = {">=$(=Date(vBeginDate4))<=$(=Date(vEndDate4))"} >} [Unavailable Start Date] )


If not working check whether the date format in variables and dimension are same.


Regards,

Jagan.

Not applicable
Author

Thanks Jagan and Oleg,

I used this expression:

=count( {$< [Unavailable Start Date] = {">=$(=Date(vBeginDate4))<=$(=Date(vEndDate4))"} >} [Unavailable Start Date] )

And it works fine.

jagan
Partner - Champion III
Partner - Champion III

Hi,

Please close this disucssion, so that it would be helpful for others to identify solution for similar tasks.

Regards,

Jagan.