Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Impossible Expression: Apparently "9 = 9" = False?!

Hiya Guys,

This is a good one!

I am trying to evaluate if the Month selected is equal to the current month (7) + 2 (September).  In a macro I am (essentially) using the VBScript:

If (ActiveDocument.Evaluate("GetFieldSelections(MonthNumber,',',12)") = (Month(Now())+2)) then ...

My "IF" expression always returns "False".  However, if I use the same expression for a Text Object (ie: =(GetFieldSelections(DateCourse_MonthNumber,',',12) = (Month(Now()))+2)) then selecting Month 9 (September) will display "-1" (True).

If anyone has any ideas please let me know - as, I am fairly sure, that "9" does in fact equal "9"...  🙂

Cheers,

Steve.

1 Solution

Accepted Solutions
Not applicable
Author

I solved this myself (but will post as it may help others in the future).

I was able to get the correct result by "adding zero" to my "GetFieldSelections" result... meaning that 9+0 = 9!!!  🙂

This must have been a casting issue - although I could not get Num() or Text() to work correctly.

Does anyone know of a better way?  I was saving ther result of "GetFieldSelections" into a variable within my macro - so perhaps using the "Dual" function may have helped?

Cheers,

Steve.

View solution in original post

3 Replies
CELAMBARASAN
Partner - Champion
Partner - Champion

I think IF expressiion should be

If (ActiveDocument.Evaluate("GetFieldSelections(MonthNumber,',',12)) = (Month(Now())+2)")

Not applicable
Author

I solved this myself (but will post as it may help others in the future).

I was able to get the correct result by "adding zero" to my "GetFieldSelections" result... meaning that 9+0 = 9!!!  🙂

This must have been a casting issue - although I could not get Num() or Text() to work correctly.

Does anyone know of a better way?  I was saving ther result of "GetFieldSelections" into a variable within my macro - so perhaps using the "Dual" function may have helped?

Cheers,

Steve.

CELAMBARASAN
Partner - Champion
Partner - Champion

You can use CInt() to convert to integer.