Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello all,
I have a chart where I want to use a dynamic variable name in a chart expression.
The variables are complicated expressions but essentially just return a value and where the name of the variables are based on the numeric representation of the chart dimension [Trans May]. For example, [Trans MaY] for 'Feb 2010' has a corresponding variable 'v40238S'. I have tried using (amongst others) the chart expression:
sum(TransVal) / $(v$(=num([Trans MaY]))S)
but this doesnt work or rather it does work but only when a specific [Trans MaY] is selected.
I hope the attached example qvw shows the issue.
Any help much appreciated.
Regards,
Gordon
Hi,
I try to find the problem, but i don't know what happened.
When use the sintax $(), will return just a one row when is select how you say.
You can see when are create a field with edit expression.
=NUM([Trans MaY]) returned all rows
=$(=NUM([Trans MaY])) returned a single row when the field is select.
I go try to find a solution, but is really necessary to use a variables or have other way to find a solution?
Thanks for the reply Eduardo.
Basically the number in the variables represents values based another table which does not share the chart dimension. By holding the values as variables and then referring to them in the charts I was hoping to return the values directly - if I include the expressions held in the variable directly in the chart expression then Qlikview cannot iterate over the chart dimensions and the values just get shown under the first dimension value.
It might be that there is a solution without the need for these variables - maybe I am too interested in understanding it rather than finding another solution!
Regards,
Gordon
This example use a INPUTFIELD and show the result as you want but not need to create a variable with exist new dates.
Gordon,
Assign the following expression to a value (including the equal sign):
=concat('v' & num([Trans MaY]) & 'S','+')
and in your graph put $(New_Variable) and it should work even if you don't select any month.
Regards.
Hi Karl,
Thanks for the reply, but I am not sure what you mean as the expression just returns the total of all the variable rather than the one that corresponds to the dimension.
Am I missing something?
Regards,
Gordon
Hi Gordon,
I was referring to your comment,
"but this doesnt work or rather it does work but only when a specific [Trans MaY] is selected."
With the changes I made as mentioned in my above post, the expression works even if you don't select a specific [Trans MaY].
I have a small typo in my previous post. I wanted to say,
"Assign the following expression to a variable (including the equal sign):"
That 's why you make the graph caption equal to $(New_Variable) which will return a list of [Trans MaY] with a plus sign between each value and then sum the values.
See the attached example.
Hi Karl,
There is a relationship between the dimension and the variable where the variable is based on num([Trans MaY]). For example, [Trans MaY] for 'Feb 2010' has a corresponding variable 'v40238S'.
I have got around the problem by constructing a variable in the load script that is a test on the generated corresponding variable name. It means a lot of 'ifs' but I couldnt find another way of returning the value as a recognisable variable name - I guess the functions return for example 'v40238S' rather than v40238S. Attached is the updated document.
Thanks for your help - if you can find an alternative to the 'ifs' I would be very happy 🙂
Regards,
Gordon
Gordon,
I don't think there is a simple solution to this. Since will want to expand the variable before assiging the value that corresponds to the dimension unless you use an if or pick and putting an = before a variable ignores dimension.
The only thing I can recommend is changing the Link field to hold 1,2,3,4, etc. and then using a pick(Link, v40238S,v40057S, etc.). That might be cleaner then the if.
Regards.
The little detail of equal sign helped me a lot!! Thank you very much.