Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

SET ANALYSIS : Previous month = Current month

Hi everybody

Can someone explain why this formula doesn't return preivous month result but current month result ?

sum (mois_ref={'=$(vPreviousMonth)'}>} if(id<>2 and (type = 2 or pos < 0), lig)) 

vPreviousMonth = max(mois_ref)-1

I reckon you shouldn't worry about IF test.

It is a SET I use quite often for years.

Best regards

Chris

1 Solution

Accepted Solutions
Gysbert_Wassenaar

To begin with I would get rid of the = in front of the $(vPreviousMonth). Next, is mois_ref a number or a text value? max doesn't work on strings. Finally the expression in the variable should be =max(mois_ref)-1, not just max(mois_ref)-1. So include the = in the variable. Otherwise weird things may happen because the variable will be evaluated in place in the sum expression.


talk is cheap, supply exceeds demand

View solution in original post

6 Replies
Gysbert_Wassenaar

To begin with I would get rid of the = in front of the $(vPreviousMonth). Next, is mois_ref a number or a text value? max doesn't work on strings. Finally the expression in the variable should be =max(mois_ref)-1, not just max(mois_ref)-1. So include the = in the variable. Otherwise weird things may happen because the variable will be evaluated in place in the sum expression.


talk is cheap, supply exceeds demand
Not applicable
Author

Hy Gysbert,

I tried removing = sign but the result is the same.

Mois_ref is a num and my vPreviousMonth was defined as =max(mois_ref)-1.

I just misunderstand the behavior.

I hope you'll be clever than me

Chris

Gysbert_Wassenaar

Then you'll have to post a document that demonstrates the problem.


talk is cheap, supply exceeds demand
Not applicable
Author

I'm sorry Gysbert I can't

But thank you anyway for your answer.

Chris

Gysbert_Wassenaar

Perhaps you can: Preparing examples for Upload - Reduction and Data Scrambling


talk is cheap, supply exceeds demand
Not applicable
Author

Yes I know but there are too many data to scramble

It is just a matter of time

But I came back on the Set which was more complex than the one I posted and rework everything from variable to a specific numeric field and removing = sign

And it works

I must say I appreciate your advices on many post

So thank you.

Chris