Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Remove all dimensions except specific with macro

Hi there

I'm trying to remove all dimensions from a chart using a macro but I don't want to remove 2 specific dimensions.

I have this code that removes all dimensions:

set chart = ActiveDocument.GetSheetObject("CH01")

'clean chart

set dims = chart.GetProperties.Dimensions
set exps = chart.GetProperties.Expressions

for i=0 to dims.Count

chart.RemoveDimension 0

next


I thought I could just put an if statement within the for loop to skip the remove for my desired dimensions but I can't work out the syntax, please can anyone advise?

Cheers

2 Replies
d_pranskus
Partner - Creator III
Partner - Creator III

Hi

Please try the following code


set chart = ActiveDocument.GetSheetObject("CH01")
'clean chart
set dims = chart.GetProperties.Dimensions
set exps = chart.GetProperties.Expressions
j = 0
for i=0 to dims.Count
if Condition Then
chart.RemoveDimension j
else
j = j + 1
end if
next


Cheers
Darius

Not applicable
Author

Hi thanks for answering - I can see where you're going but what would the syntax for "Condition" be? For instance if I don't wnat to remove a dimension called "Name"? Thanks