Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Problems using variables and macros

HI

we have been working on an application and i have noticed something strange that i have never seen before......

We have a simple expression SUM([Investment Value) which works absolutely fine and gives the below result:

Jan 2012 - 141,999

Feb 2012 - 120,747

However, when i create a variable for this expression it doesn't work.  The variable i created was vInvestment_Value.  When used in the expression i put in $(vInvestment_Value).  The results we get are:

Jan 2012 -  262,746

Feb 2012 - 262,746

which is the sum of all values.  i really don't understand why it isn't working.  We tried creating other variables to replace expressions we used and exactly the same thing happened.  Does anyone have any ideas why variables are not working.

The reason i need to get them to work is I have written a macro which allows people to build their own charts with pre defined dimensions and expressions.  In order for this macro to work i need to create a variable with the expression in it.  This macro isn't working either and i can't see why as I have used it many times before.  I think it is something to do with the variables not working but if anyone has any ideas on this we would be interested to here them.  For example to you have to set some setting in order for macros to work?

Thank you

2 Replies
m_woolf
Master II
Master II

The variable calculates outside of the chart and doesn't use the chart dimension in the calculations.

Look in the API Guide for examples of how to set a chart's expression with code.

brenner_martina
Partner - Specialist II
Partner - Specialist II

Hi,

how did you define your variable? It must look like this:

SUM([Investment Value])

without the Equal-sign!!!

Greetings from Munich

Martina