Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Hide gauge indicator/needle when expression is null.

I'm trying to hide/show the indicator of a gauge chart depending on what the expression calculation results in. The min val of the gauge is 0 (as in 0 %) and max val is 100 (as in 100 %). The gauge chart shows how many activities of a certain type that started in time.

If 3 of 4 activites started in time the indicator will point at 75 %.

If 0 of 4 activities started in time the indicator will point at 0 %.

But if there are no activities of the certain type, i.e. 0 of 0 activities started in time, I want to hide the indicator since it would be incorrect to say that 0 activities started in time. The result is actually null.

I use a macro to hide/show the indicator:

set chart = ActiveDocument.GetSheetObject("CH616")

set props = chart.GetProperties

set gaugeSettings = props.ChartProperties.GaugeSettings

gaugeSettings.GaugeShowIndicator = false

chart.SetProperties props

The problem is that I can't find a way of reading the expression result in the macro. I should need something like the bold text below:

if chart.getexpression("ActivitiesStartedInTime").value = null() then

     gaugeSettings.GaugeShowIndicator = false

else

     gaugeSettings.GaugeShowIndicator = true

end if

Is there a way of doing this or is it possible to achieve what I want with another approach?

4 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

Hi

It is better to use the conditional show feature to selectivly show or hide a sheet object. This works equally in all clients, whereas macros are client sensitive; and the conditional show operates automatically without needing to be triggered.

Go to Properties | Layout for the guage. Select Conditional and enter the following expression in the Conditional Show box:

=If(IsNull(<your guage expression here>), 0, 1)

Hope that helps

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

Hi,

The conditional show on the entire gauge object works fine - thanks! - but it doesn't really fulfill what I want to achieve. The end users would probably be quite confused when the entire gauge is missing. I don't think they would interpret that as 0 actions, but rather as "something has gone wrong here".

I wish there was a conditional show on the indicator itself...

However, if I add a text object that is shown when the gauge is hidden I could inform the user about the 0 actions there. If I don't get any other suggestions on how to solve this problem I will likely go for that solution.

Thanks Jonathan!

Sara

kji
Employee
Employee

You can use the "Calculation Condition" found on the "General" tab of the chart properties, this will show a text instead of the Gauge ( defaults to "Calculation condition unfulfilled" but that can be changed under "Error Messages..." button on the same tab.

Not applicable
Author

Of course! Thanks for your comment, Johan! The calculation condition solution is much more stylish.