Skip to main content
Announcements
Qlik Community Office Hours - Bring your Ideation questions- May 15th, 11 AM ET: REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Dayna
Creator II
Creator II

Expressions as a selector...

Dear all,

Possibly an easy one, I have three expressions in my chart, but what I would like to do is have these three expressions as a selector, and then show these in the chart.

I.e. if I had open, closed and resolved as my options in a field it would show me three bars, however, I might only want to see Open and Resolved so I'd like to click these in a list box and show them in the chart...

Could you advise as to how I could achieve the above?

Many thanks!

Dayna

3 Replies
Not applicable

May be you can try loading data and then create cycle, Please see attached qvd.

Not applicable

Here is a way to do it with macros. First, you need an Inline load with each of the expressions to be selected:

LOAD * INLINE [
Expressions
Exp 1
Exp 2
Exp 3
];


Then create a variable to store the selected values in that field. This can also be handled directly in the macro, but I think the variable way is easier. I set up a variable, vExpShow, with the expression:

=GetFieldSelections(Expressions)


Then go to Document Properties and set a Trigger for the OnSelect of the Expressions field. Set it to External>Macro and then create the following macro:

Sub Test
set chart = ActiveDocument.GetSheetObject("CH01")
set p = chart.GetProperties
var = ActiveDocument.Variables("vExpShow").GetContent.String

set expr = p.Expressions.Item(0).Item(0).Data.ExpressionData
If InStr(var, "Exp 1") Then
expr.Enable = true
Else
expr.Enable = false
End If
chart.SetProperties p

set expr = p.Expressions.Item(1).Item(0).Data.ExpressionData
If InStr(var, "Exp 2") Then
expr.Enable = true
Else
expr.Enable = false
End If
chart.SetProperties p

set expr = p.Expressions.Item(2).Item(0).Data.ExpressionData
If InStr(var, "Exp 3") Then
expr.Enable = true
Else
expr.Enable = false
End If

chart.SetProperties p
End Sub


I've attached a sample.

Jason_Michaelides
Luminary Alumni
Luminary Alumni

Fantastic solution NMiller!  This and another post gave me the basis for my looped version so all expressions are included without having to add more code to the macro.  Thanks!

Sub ActivateChartLines

          set chart                         = ActiveDocument.getSheetObject("CH73")

          set p                              = chart.GetProperties

          set chartExpressions          = p.Expressions

          chartExpressionMax               = chartExpressions.Count - 1

          var = ActiveDocument.Variables("vChartLines").GetContent.String

          for i = 0 to chartExpressionMax

                    set expr = p.Expressions.Item(i).Item(0).Data.ExpressionData

                If InStr(var, i+1) Then

                         expr.Enable = true

                    Else

                         expr.Enable = false

                    End If

          next

          chart.SetProperties p

End Sub