Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
May 18th 10AM ET, Live Chat, bring your QlikView questions. REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

swap expression order in graph using VB script

Hello,

I have a QV pivot chart with 3 dimensions and 2 numerical expressions, vertically displayed as bars. The chart is sorted descending on the first expression. I can sort on the second by moving it up in the expression tab of the graphs properties sheet, but i want to make a button to have VB automatically perform this. I have tried the following, but it does not work

<pre>Sub swap_order

Set obj = ActiveDocument.GetSheetObject("CH03")
Set props = obj.GetProperties
Set exprs = props.Expressions
Set tmp_0 = exprs.item(0)
Set tmp_1 = exprs.item(1)
exprs.item(1).copyfrom(tmp_0)
exprs.item(0).copyfrom(tmp_1)
End Sub


I would be really grateful if someone could tell me how to perform this in VB !

with kind regards, Jurjen van der Hoek

2 Replies
Not applicable
Author

Hi

You could add another expression to your chart, a copy of the first one.
Then you can disable the first or the third expression to switch the order.

regards
/Fredrik

Not applicable
Author

Hi Fredrik, thanks for your reply. I think yoyr suggestion is alright, but making a copy of an expression is not as simple as it might seem. Within the Graph class, there is method AddExpression, but it just has a text argument:

obj.AddExpression ("count([RFCT-refgmt])")

In this way, many properties of the expression are not copied as they are. In my post i also try to make a copy, but my method does not work. Thanks again though, and any other suggestion is welcome

with kind regards, jurjren van der Hoek