Qlik Community

QlikView App Development

Discussion Board for collaboration related to QlikView App Development.

laujerry
Contributor

qlikview macro about chart

hi all,

i have 2 questions

#1

how can i count the number of expressions in macro?

the getcolumncount function can only return count of visible columns

but i want to count all expressions including those hidden by condition expression

i.e. how could i possibly count this -> chart.getproperties.expressions.item

#2

in this expression, chart.getproperties.expressions.item(0).item(0).data.expressionvisual

the first item(i) refer to the expression (0,1,2,3..)

and how about the second item?

Thanks

Jerry

1 Solution

Accepted Solutions
MVP & Luminary
MVP & Luminary

Re: qlikview macro about chart

With the following code could you get the number of expressions within a chart (independing if they are active or inactive or hidden from a condition):

set chart = ActiveDocument.GetSheetObject("CH01")

set cp = chart.GetProperties

expr = cp.Expressions.count

msgbox expr

and with this count you could loop trough all expressions and read their various properties. For doing this I suggest to use the APIGuide.qvw to get the various possible properties and the right syntax.

- Marcus

View solution in original post

4 Replies
MVP & Luminary
MVP & Luminary

Re: qlikview macro about chart

With the following code could you get the number of expressions within a chart (independing if they are active or inactive or hidden from a condition):

set chart = ActiveDocument.GetSheetObject("CH01")

set cp = chart.GetProperties

expr = cp.Expressions.count

msgbox expr

and with this count you could loop trough all expressions and read their various properties. For doing this I suggest to use the APIGuide.qvw to get the various possible properties and the right syntax.

- Marcus

View solution in original post

laujerry
Contributor

Re: qlikview macro about chart

thank you marcus

i have the api.qvw on hand but i find it hard to look for precisely what i need just like what i have asked in this post

can i find the answer of question 2 in the api qvw?

MVP & Luminary
MVP & Luminary

Re: qlikview macro about chart

That's definitely not easy and you will need some time to search through the examples and you will need a systematically approach - searching starting within the listbox "Member", looking which entries from the listbox "Class" are possible, selecting one and then deselecting "Member" again, to see which entries belong to the "Class"-selection and so on. Helpful is also to put: =info(Classmember) within a new listbox which meant you could search trough all examples and not only seeing a single one within the example-textbox.

If you look on the following example you will see that also the attribute-expressions will be assigned to item(0).item(0):

set chart = ActiveDocument.Activesheet.CreatePivotTable

chart.AddDimension "ProductType"

chart.AddExpression "sum(Amount)"

set cp = chart.GetProperties

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

set bce = expr.AttributeExpressions.BkgColorExp

bce.Definition.v = "if(ProductType='Soap', red(), yellow())"

chart.SetProperties cp

Therefore what is the aim to count all expression-parts and/or to read their properties?

Another example which might be useful to find a logic for the second item(0) could be this:

rem this example makes a chart with a subexpression and then shows how to access

set chart = ActiveDocument.Sheets("Main").CreateLineChart

chart.AddDimension "ProductType"

chart.AddExpression "sum(Amount)"

chart.AddErrorExpression "stdev(Amount)",0,0  'symmetric error expression

set cp = chart.GetProperties

set expr = cp.Expressions.Item(0).Item(0)    ' 1st main expression

for i = 0 to expr.SubExpressions.Count-1

    msgbox(expr.SubExpressions.Item(i).Data.ExpressionData.Definition.v)

next

Another approach to find the properties and their place within the object-model could be to export the document-layout from the application and to look there within the xml how the object-structure looked like.

- Marcus

laujerry
Contributor

Re: qlikview macro about chart

it is not convenient as expected, but thank you for your guidelines