Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Variable Within If Statement not working as expected - Please Help!

Hi all,

I have created a simple Sum IF expression which includes a variable. I have created the variable within the variable overview within the document, variable works fine, however it fails to work within the expression;

Variable:    vMaxOrdMon = Max([Month Num Ord])

The variable returns the number '3' when displayed in a text box: =$(vMaxOrdMon)

So the variable is working correctly;

I have then created an expression which uses the variable:

=Sum(If([Month Num Tar] > 0 AND [Month Num Tar] <= $(vMaxOrdMon),[Target Value], 0))

This is however returning null? - Very frustrating, cant think for the life of me why!?!

If you replace the variable with the number '3' the expression works fine and correctly returning the correct value (1765.94).

=Sum(If([Month Num Tar] > 0 AND [Month Num Tar] <= 3,[Target Value], 0))

This is returning 1765.94; the correct resulting value;

Any idea why the variable does not work within the expression?

Any help greatly appreciated;

Joe

1 Solution

Accepted Solutions
Not applicable
Author

Thanks for your response Sokkorn;

The variable is definitely returning a number value of 3; One of the first things I thought of too;

I have actually now got the expression working by re-creating the variable, re-created it exactly the same, but it now works correctly!!

Just one of those QV things I guess...

Thanks again anyway,

Joe

View solution in original post

2 Replies
Sokkorn
Master
Master

Hi Joe,

Make sure $(vMaxOrdMon) return 3 not '3'. Or you can try set analysis with this expression =SUM({<[Month Num Tar]={">0<=$(vMaxOrdMon)"}>} [Target Value])

Let me know if it not work.

Regards,

Sokkorn

Not applicable
Author

Thanks for your response Sokkorn;

The variable is definitely returning a number value of 3; One of the first things I thought of too;

I have actually now got the expression working by re-creating the variable, re-created it exactly the same, but it now works correctly!!

Just one of those QV things I guess...

Thanks again anyway,

Joe