Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Reusable Calculation Rule and SET Analysis

Hi,

I will need certain calculation rules in my application:

e.g. if(Variable1=1 AND Field1='ABC', ValueField1, if(Variable2=1 And Field2=1, ValueField2),0)

This calculation will be used in tables and also I would like to use the same rule in SET Analysis when building charts. So I want to store this rule in a variable using the variable dialogue e.g. VariableCalc =if(Variable1=1 AND Field1='ABC', ValueField1, if(Variable2=1 And Field2=1, ValueField2),0)

If I now use the variable in a SET Analysis Expression it does not calculate. For instance I wrote:

Sum({<Field4=>VariableCalc) or Sum({<Field4=>$(VariableCalc))             ----> Should calculate the sum and ignore selected values in Field4

If I put the if Statement directly in the SET Analysis it calculates. The SET Analysis would then look like

Sum({<Field4=>if(Variable1=1 AND Field1='ABC', ValueField1, if(Variable2=1 And Field2=1, ValueField2),0))

My question is how do I have to store the calculation rules in order to reuse it in tables and charts and how do I correctly use them. I found a couple of documents dealing with SET Analysis and variables but most of them refer to use variables in the dimensions.

Thanks for your help!!!

1 Solution

Accepted Solutions
Gysbert_Wassenaar

Missing curly brace perhaps: Sum({<Field4=>}$(VariableCalc))


talk is cheap, supply exceeds demand

View solution in original post

5 Replies
Anonymous
Not applicable
Author

try this Expression:

Sum({<Field4={'>$(=VariableCalc)'}>}Value)

Gysbert_Wassenaar

Missing curly brace perhaps: Sum({<Field4=>}$(VariableCalc))


talk is cheap, supply exceeds demand
Anonymous
Not applicable
Author

Thanks for the hint with the curly brackets. I correctly set them. I just missed them in the post. So my SET Analysis using the variable would look like:

Sum({<Field4=>}VariableCalc)

But it is still not working 😞

Gysbert_Wassenaar

Can you post a small qlikview document with some example data that makes clear what you're trying to do?


talk is cheap, supply exceeds demand
Anonymous
Not applicable
Author

Sorry, I have checked again with your proposal. And it now works fine. I had to take the = away in the variable definition and then using the $() around the variable in the expression.

Thank you for your help!!!

Marcel