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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
jedgson
Creator
Creator

Can a user hide an expression in a chart?

Hi,

I have a chart which has 4 expressions:

Total (Displayed as a Bar)

% X of total (Displayed as a Line)

% Y of total (Displayed as a Line)

total X of total (i.e. if Total = 200 and '% X of total' = 50% then 'total X of total' would = 100) (Displayed as a Line)

What I would like to be able to do is allow the end user to select which expressions are visible on the chart. Is this possible?

Jay

1 Solution

Accepted Solutions
Anonymous
Not applicable

Jay,
It is possible using macro. You'll need a button for each expression which you want to hide/show. Macros will be like these:


sub Test
set chart = ActiveDocument.GetSheetObject("CH01")
cp = chart.GetProperties
set expr = cp.Expressions.Item(0).Item(0).Data.ExpressionData
if expr.Enable = 0 then
expr.Enable = true
else
expr.Enable = false
end if
chart.SetProperties cp
end sub


View solution in original post

4 Replies
Anonymous
Not applicable

Jay,
It is possible using macro. You'll need a button for each expression which you want to hide/show. Macros will be like these:


sub Test
set chart = ActiveDocument.GetSheetObject("CH01")
cp = chart.GetProperties
set expr = cp.Expressions.Item(0).Item(0).Data.ExpressionData
if expr.Enable = 0 then
expr.Enable = true
else
expr.Enable = false
end if
chart.SetProperties cp
end sub


johnw
Champion III
Champion III

Attached is the approach we're using. It's probably overkill for your situation, but you may be able to mine information from it. I haven't checked if it works in 9.0, but it works in 8.5.

jedgson
Creator
Creator
Author

John,

This is perfect for what I need thanks.

I am tryin to ammend the Macro to set properties for the Dimensions in the Chart.

I am trying to set the 'Suppress Null values' and change the sort to 'Load Order'

For suppress Null Values I have added this:



chartDimensionMax = chart.GetColumnCount - 1
set dims = chartProperties.Dimensions
for i = chartDimensionMax to 0 step -1 'remove existing dimensions
chart.removeDimension(i)
next
for j = 0 to selectedDimensionMax 'add selected dimensions
chart.addDimension(selectedDimensions.Item(j).Text)
dims(j).NullSuppression = true
next




Unfortunately this keeps failing with 'Invalid procedure call or argument'

Can you see where I am going wrong.

Jay

jedgson
Creator
Creator
Author

I have managed to do this now. Thanks for your help

Jay