
Re: How to creat dynamic expressions  Fieldvalues to a new Field?
Stefan Wühl May 2, 2014 10:48 AM (in response to Dennis Schulze)But you want 1 expression, that kind of switches based on the current dimension value?
Then you need to create something that will end up in an expression like
=pick( match(Dimension, 'Sales', 'Turnover', 'Amount')
,sum(Sales)
,sum(Turnover)
,sum(Amount)
)
You can create this expression in your script, there is an example in the forum how to do this, just can't find it right now.
edit:
found one:

Re: How to creat dynamic expressions  Fieldvalues to a new Field?
Jonathan Dienst May 2, 2014 10:53 AM (in response to Dennis Schulze)Dennis
Let me see if I understand you correctly  you would like to have a set of dynamic expressions calculated in a chart (or table) and you are trying to use set analysis to get the correct expression of each line based on a the expression number or name as a chart dimension?
This won't work I am afraid, as the set expression is evaluated once for the chart before the dimensions are created and has no concept of the dimension. The way to solve this problem is to construct a Pick(Match()) type of expression. So let's say that you have the field 'fact' as a dimension. Then you would need an expression like:
Pick(Match(fact_ID, '10', '20', '30'),
Sum(var_sales),
Sum(var_turnover),
Sum(var_amount)
)
If you have a few expressions, then this is quite easy to create. If there are many expressions (I had up to 50 in a recent document), then you will need to construct the Pick(Match()) into a variable and then use
$(vPickMatch)
to execute the variable.
HTH
Jonathan