Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
mambi
Creator III
Creator 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
Champion III
Champion III

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

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
mambi
Creator III
Creator III
Author

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.

marcus_sommer

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
Creator III
Creator III
Author

doesn't work for me

maybe because I'm using a combo chart ?!