Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Macro to add condition to expression

Hello all,

I was wondering if there is any kind of way that will allow me to add a condition to expressions through macros. At the moment I have a macro that dynamically adds expressions to a chart and I want to make sure the expressions are alwys greater than zero. Otherwise they shouldn't apper in the graph. Looking at the API the only thing I found was EvaluationCondition command, which only applies to table objects though. Any ideas?

4 Replies
Not applicable
Author

So doesn't anyone have any clue about this? I'd be surprised if there is no way to programmatically insert conditions for expressions.

IAMDV
Luminary Alumni
Luminary Alumni

Hi,

I know this is very old thread but have you got around a way to add conditional expressions using VB Script?

Thanks,

DV

marcus_sommer

Have a look here: Macro for Conditional expression in chart

- Marcus

long_huynh
Luminary
Luminary

Recognise that this is quite an old thread but the answer is found in bold and underlined in the example code below:

set chart = ActiveDocument.ActiveSheet.CreateStraightTable

chart.AddDimension "Customer"

chart.AddExpression "sum(Amount)"

set cp = chart.GetProperties

set expr = cp.Expressions.Item(0).Item(0).Data.EnableCondition

expr.Type = 2

expr.Expression = "Sum(Amount)> 500"                  

chart.SetProperties cp

You first need to enable the tick the conditional option type (=2) then add the expression (you conditional expression).

Thanks,

Long