3 Replies Latest reply: Jul 12, 2012 6:48 AM by Yme Joustra

# Simple variable expressions work differently from direct expressions.

Oke, it is possibly very simple or already answered, but I have no idea what is going wrong and I tried a lot of answers on this discussion forum.

I have data like this:

2010                    value

1-1-2010           5

1-2-2010           6

1-3-2010           5

ect.

This is the result when using for 'value': sum(value), which is good!

But now I want this being saved in a variable. So I create a variable: 'total_value' with description: '=sum(value)' and then I refer the value expression to total_value so: 'value becomes' : = total_value.

When I do this the result is:

2010                    total_value

1-1-2010           16

1-2-2010           16

1-3-2010           16

ect.

Which is wrong! I still need the same results, 5 and 6. What am I doing wrong? To me it seems nothing really changed, only changed the location of calculating the values.

I do this for simplifying a query. What am I doing wrong.

Best regards.

• ###### Re: Simple variable expressions work differently from direct expressions.

...that's because you are missing the dimension '2010'...

you calculate the expression outside the chart and then paste it to every row of teh table

try this:

variable:          sum(value)

exp in chart:    \$(variable)

• ###### Re: Simple variable expressions work differently from direct expressions.

Hi

A variable that starts with and = sign is evaluated immediately (ie outside of the chart). Outside the chart the total is 16 (same as entering =sum(value) in a text box).

If you want to use an expression value in a chart, you must save it without the '='

Let total_value = 'sum(value)';

or

Set total_value = sum(value);

The use the expression in the chart =\$(total_value)

Hope that helps

Jonathan

• ###### Re: Simple variable expressions work differently from direct expressions.

Yes, that makes sense! Thank you for the explanation. This helped me a lot