Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to remove a dimension from a Graph with macro

Hello World 🙂

i need help for deleting dimensions and expressions from a Graph with macro...

It' possible to develop a macro that allows to delete a dimension knowing only the name of the dimension?

There is a way to get the index of a dimension knowing only the name of the Dimension?

Please see the attached file.

Thak you all.

Raffaele

1 Solution

Accepted Solutions
Not applicable
Author

Found the solution.

Function gestiscidimensione()
dim i, titolo, ud
sChartId = "personalizzata"
set table = ActiveDocument.GetSheetObject(sChartId)
ud = table.GetProperties().Dimensions.count-1
if (ActiveDocument.Variables("b_dimensione").getcontent.string)=1 then

Table.AddDimension (ActiveDocument.Variables("v_dimensionebld").getcontent.string)
set cp = table.GetProperties
set dims = cp.Dimensions
dims(dims.Count-1).Title.v = (ActiveDocument.Variables("v_dimensionebld").getcontent.string)
table.SetProperties cp

else
for i=0 to table.GetProperties().Dimensions.count-1
titolo = table.GetProperties().Dimensions.Item(i).Title.v
if titolo=(ActiveDocument.Variables("v_dimensionebld").getcontent.string) then
Table.RemoveDimension i
exit for
end if
next
end if
end Function

View solution in original post

9 Replies
Chanty4u
MVP
MVP

Not applicable
Author

Thanks but I had already seen this tread but does not solve my problem...

HirisH_V7
Master
Master

Hi ,

Conditional dimension display with macro

Hope this helps you out,

Hirish

HirisH
Anonymous
Not applicable
Author

marcus_sommer

Are you really sure that you need macro-routines which delete dimensions and maybe also create which one or even whole objects - quite often you could get similar results if you used objects with conditions on the objects, dimensions and expression.

- Marcus

Peter_Cammaert
Partner - Champion III
Partner - Champion III

Don't use macros, use 'Conditional Show'. That one will work in the AccessPoint too.

Not applicable
Author

i know... but this is the request of our customer:

1. Starting from an empty graph

2. Ad Dimensions to the graph (by clicking a different button for each dimension)

3. Add Expressions to the graph (by clicking a different button for each expression)

4. Save Configuration duplicating the graph

so i can't use conditional show.

I can easily add dimensions and expressions to my object but i can't remove them because i'm expected to state dimensions and expressions  index and not their names.

thanks

marcus_sommer

Does your customer know that there are other possible ways to create and use dynamic charts? What are the features which only a macro provided - I didn't understand your fourth point with "save configuration" - what will be saved for which reason?

- Marcus

Not applicable
Author

Found the solution.

Function gestiscidimensione()
dim i, titolo, ud
sChartId = "personalizzata"
set table = ActiveDocument.GetSheetObject(sChartId)
ud = table.GetProperties().Dimensions.count-1
if (ActiveDocument.Variables("b_dimensione").getcontent.string)=1 then

Table.AddDimension (ActiveDocument.Variables("v_dimensionebld").getcontent.string)
set cp = table.GetProperties
set dims = cp.Dimensions
dims(dims.Count-1).Title.v = (ActiveDocument.Variables("v_dimensionebld").getcontent.string)
table.SetProperties cp

else
for i=0 to table.GetProperties().Dimensions.count-1
titolo = table.GetProperties().Dimensions.Item(i).Title.v
if titolo=(ActiveDocument.Variables("v_dimensionebld").getcontent.string) then
Table.RemoveDimension i
exit for
end if
next
end if
end Function