Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello, I'm pretty new to Qlikview, hopefully someone can help me.
I´m using this code:
if(Left(Rubrik,1)=' ' or isnull(Rubrik),'',(sum( if(År=IndexÅr and BokfPeriod<=AktuellMånad,(BokförtBelopp),0))
-sum( if(År=JämförelseÅr and BokfPeriod<=AktuellMånad,(BokförtBelopp),0))))
I want to store this expression in a variable, but it doesn't work. If I store the above to an variable named "Var1" , can I just use it in my expressions or to I have to do something withc SET or/and LET?
First, you probably need to precede your variable definition with an equals sign. That way it can be used in an expression and will be evaluated while the expression is. Set and Let are used within your script to define variables. I believe they are for the most part equivilent, so if you are trying to define this using the Variable Expressions dialog, then you don't need to worry about Set or Let.
Have you tested out that expression to make sure it is working as intended. Using it in a chart expression is an easy way to test it. The reason I ask is because having a Sum inside part of an If is throwing me off a bit. In your expression, won't it look at the first record to see if Rubrik is null and then only Sum if it is not. I'd think you'd want to only set the expression to Null if all values of Rubrik were null. Maybe you could give a little more detail as to what that expression is supposed to do.
Thanx for quick reply!
I know that the expression works, I´m using it in a chart today, but the reason I want to put it in a variable is that I want to use it in big If-expression and it gets so difficult to read.
I have the expression like above and one more quite similiar (the same but previos year).
Now I want to take the first expression minus the second one, but only if the expression below is fulfilled, othervise I want to have the second expression minus the first.
if(((avg(trim(Nivå))=32 or avg(left(Nivå,2))=30)
I had a little trouble trying to put together an example. In the past, I've used variables for portions of my expressions, so I'm not sure of the limitations when using a variable for the entrie formula (with aggregation).
In order to use your variable in an expression, you need a dollar sign expansion. If you have a variable named vTest, you can use it in your expression with $(vTest).
So, something like this?:
if((avg(trim(Nivå))=32 or avg(left(Nivå,2))=30), $(Variable1), $(Variable2))
Yeehaaa!!
Works perfectly! Thank you very much!