Qlik Community

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

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.

Tags (2)
1 Solution

Accepted Solutions
Not applicable

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

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.

3 Replies

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

I think IF expressiion should be

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

Not applicable

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

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.

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

You can use CInt() to convert to integer.

Community Browser