Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all,
I have a little issue where I'm trying to transfer all my expressions into variables but in the cases where I have one expression which is part of another expression, when I change it to refer to the variable it doesn't seem to be working. The results are as if it's ignoring the second part of the expression and just give me the numbers relative to the first variable.
Please see what I've done below.
vLocalPrice --> If(Stream = 'UNKNOWN', Avg([PAC - NA]), Avg(PAC))
The formula for my budget is as below. It works.
You can see that the bold part is my local price which is stored in vLocalPrice as above.
If(Stream = 'UNKNOWN', Avg([PAC - NA]), Avg(PAC)) * Sum(Target)
Now, when I replace the local price expression above by my variable vLocalPrice (as below) the results are wrong. The results are the same as the results I get for from vLocalPrice. As if the exprecion below is ignoring "* Sum(Target)".
$(vLocalPrice) * Sum(Target)
I had a look around on the community and also some other blogs but there's no example where I have a variable calling another variable.
Could someone help with this one?
Are you putting a preceding '=' sign in your variable definition? If so, try removing that. Otherwise, create and share a qvw with sample data that demonstrates the issue.
Hi,
This is working, don't give = in variable declaration
vLocalPrice --> If(Stream = 'UNKNOWN', Avg([PAC - NA]), Avg(PAC))
and
=$(vLocalPrice) * Sum(Target)
If it is not working then try like this
vLocalPrice --> Avg({<Stream = {'UNKNOWN'}>}[PAC - NA]) + Avg({<Stream -= {'UNKNOWN'}>}PAC)
and
=$(vLocalPrice) * Sum(Target)
Is Stream is there in your dimension?
Regards,
Jagan.
Thanks for the quick turnover tresesco.
No I'm not using '=' in my variable definitions.
I think it'll be too hard for me to create a dummy version of my model. It's too complex.
I was hopping it'd be something obvious in my syntax that someone could spot straight away. Does that mean the syntax is correct?
How would you add a variable inside another variable? Could you give me an example?
The reason I'm asking is because, as I said below, when I replace the variable by the actual expression it works.
And this is the expression I'm using in my straight table:
=$(vBudget)
vBudget --> If(Stream = 'UNKNOWN', Avg([PAC - NA]), Avg(PAC)) * Sum(Target)
Hi jagan,
Thanks for the suggestion. Yes, Stream is my dimension.
Your set analysis is summing PAC-NA with PAC. I don't think it's what I want. I need to have a conditional where if it's UNKNOWN it uses PAC-NA otherwise PAC.
Cheers
Thanks tresesco.
Nevertheless, how would you write your syntax to have a variable calling another variable?
I am having attachment issue since yesterday(getting the options right, but after pressing on 'Save Reply'/'Insert', it goes nowhere ). Sara Leslie, could you please help?
Marcos,
Example:
vSum -> Sum(Amount)
vvCondSum -> If($(vSum)>100, 'More than one hundred', '<= one hundred')
Check this blog too: the-magic-of-variables
Hello Marcos,
Please find the below attachment. I have created a sample application for the requirement you have requested for. This might help you.