Qlik Community

QlikView Creating Analytics

Discussion Board for collaboration related to Creating Analytics for QlikView.

mambi
Contributor III

Calculated Dimension

Hello everyone,

i want to add a calculated dimension to a chart dynamically (via a macro), but it doesn't work

any idea ?

Sub TestFunc

  set pchart = ActiveDocument.GetSheetObject("CH01")

  pchart.addDimension " = if ( Product='AAA', Field1, Field2 ) "

  set chartProperties = pchart.GetProperties   

  pchart.SetProperties chartProperties

end sub

4 Replies
vinieme12
Esteemed Contributor II

Re: Calculated Dimension

what do you mean by doesn't work exactly

does it give an expression error? or is the macro failing to do anything

try with AGGR(  Expression, Product) if it's an expression error

mambi
Contributor III

Re: Calculated Dimension

there's no expression error and no thing is added to the chart.

if I use pchart.addDimension "AField" it works but with the if.... it doesn't.

Re: Calculated Dimension

The following worked for me:

Sub TestFunc

  set pchart = ActiveDocument.GetSheetObject("CH21")

  pchart.addDimension  "=if(Class='PivotTableBox', Classmember, Member)"

  set chartProperties = pchart.GetProperties  

  pchart.SetProperties chartProperties

end sub

and this meant that the extra spaces within the expression-string caused the error.

- Marcus

mambi
Contributor III

Re: Calculated Dimension

doesn't work for me

maybe because I'm using a combo chart ?!

Community Browser