Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
m_woolf
Master II
Master II

Macro to get the value of an expression

Can anyone post a code example of how to get the value of an expression from a chart and store it in a variable?

7 Replies
spsrk_84
Creator III
Creator III

Hi,

I had written a macro to get the Value of a expression ,but before we pass the value to a variable we need to create the variable in Document Properties and then run the macro to paas the value...

Acually i created a macro to create Bar chart and mean while i am calculating the same expression to pass the value of the expression to the Variable,please find the attached..

Sub Graph

Set Grp=ActiveDocument.Sheets("Main").CreateBarChart // To create bar chart

Grp.ADDDIMENSION "Grp" // to add dimension to the chart

Grp.AddExpression "Sum(Sal)" // to add expression to the chart

Set V=ActiveDocument.GetVariable("Value") // i am calling the Variable created earlier in Document Proprties

V.SetContent "Sum(Sal)",True // Now i am passing or setting the Variable contents with expression Value

End Sub

The above macro creates the barchart along with one dimesion and one expression and also passes the expression value to the variable which is already created...

now if u want to check whether the variable value just create ant Text Object and give the expressin like =$(Value)

Hope this will resolve ur problem

Regards,

Ajay

spsrk_84
Creator III
Creator III

Hi,

Is your macro problem resolved................

Regards,

Ajay

Not applicable

Hi Ajay,

i tried ur coding.. its working...

Instead of Text Object.. whether its possible to generate a graph dinamically when i enter the field values in a text box or list box.

thanks

bharathe

Not applicable

Hi all...

Anybody know about this please help me....

thanks in advance

spsrk_84
Creator III
Creator III

Hi,

can u explain ur requirement briefly since i didnot understand this particular thing

"whether its possible to generate a graph dinamically when i enter the field values in a text box or list box."

If u can explain exact requriment i can give some solution for that.........

Regards,

Ajay

Not applicable

hi ajay,

i m having dimensions like empid,Designation,Location etc... expression as sum(empid)

i have to get location from input box and the graph should get changed according to that inpput.

for ex.. location in inputbox

if i give US or UK or JAPAN (in input box) the graph should be created.

how to achieve this?

spsrk_84
Creator III
Creator III

Hi,

Assume u have created the input box in which u have created the variable called INPUTLOC

then

Suppose u r creating the Straight table with Dimensions like

empid,Designation,Loaction

and expression is Sum(empid)

Now u do like u enter the value in your input box and then

ur expression like this

Sum ( { $<Loaction= { ' $(INPUTLOC ) ' } > } empid)

the above written is the set expression i think u need not require any macro to do this since the value u r passing in input box will be checked

with the existing location if it is there it will display the output...

While passing the Value to Variable enter the location with as it is in Location Fiedl

i.e suppose if Location field contains data like

Loaction

UK,

USA

and u entering it as usa it will not give result since QlikView script is case sensitive...

Try this

Regards,

Ajay