Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to rename the expression that is created from macro?

Hi All,

Can any one help me i this

I am using the below code for creating the Straight table dynamically.

Sub Create
Set Obj=ActiveDocument.Sheets("Main").CreateStraightTable
Obj.AddDimension "Sal"
Obj.AddExpression "Sum(Sal)" (i am getting this field in the table with same name but i want to rename it)
End Sub 

                                                                                                                              

Now How can i rename that expreession from the macro itself.

Thanks for any help..

3 Replies
s_uhlig
Partner - Creator
Partner - Creator

Hi,

take a look at QV API-Guide. Here is the example for IGraphProperties.Expressions

set chart = ActiveDocument.ActiveSheet.CreateStraightTable

chart.AddDimension "Customer"

chart.AddDimension "ProductType"

chart.AddExpression "sum(Amount)"

set cp = chart.GetProperties

set expr = cp.Expressions.Item(0).Item(0).Data.ExpressionVisual

expr.Label.v = "Sales"

expr.NumAdjust = 1    'center

expr.LabelAdjust = 1    'center

chart.SetProperties cp

Regards

Sven

Not applicable
Author

Hi,

Thanks for your reply

But how can i mange these expressions through a loop

Thanks..

s_uhlig
Partner - Creator
Partner - Creator

Hi,

sorry, but there are thousands of possibilities

set chart = ActiveDocument.ActiveSheet.CreateStraightTable

chart.AddDimension "Customer"

for ...
     i=chart.AddExpression your_current_expression
     set cp = chart.GetProperties
     set expr = cp.Expressions.Item(i).Item(0).Data.ExpressionVisual
     expr.Label.v = your_current_label
     chart.SetProperties cp

next

you may use two arrays, a dictionary (CreateObject("Scripting.Dictionary")) or what ever you want

Regards

Sven