Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
avastani
Partner - Creator III
Partner - Creator III

Unique functionality

is there a way to disable an expression if there is no definition available for it?

what i have is a series of KPIs using the same chart only picked based on the KPI selection from a listbox.

some KPI plot 2 lines some 3 lines. I woul dlike to be able to disable the 3rd expression from being displayed as null if it does not exist for the KPI. It throws my scales off because everythign is 0 (zero) for that expression.

1 Solution

Accepted Solutions
Not applicable

We ran into a similar issue. You can have null expression and not have expression displayed in the legend. I've attached a sample qvw that does what you're looking for.

Also, QlikView will not display anything if the first expression is null so the attached qvw has dummy hidden/invisible expression that always returns a value. If the first expression is never null then you don't need the hidden expression.

View solution in original post

7 Replies
boorgura
Specialist
Specialist

Hey Amir,

you can do a conditional expression, with a condition on the selected value.

or if you want it in different charts for each selection, you can as well do a conditional-show in the layout, depending on the Current Selection.

Thanks,

Rocky

avastani
Partner - Creator III
Partner - Creator III
Author

that's what I am trying to do but cannot. Essentially, the expression should be disabled so that it does not even show in the legend because it does not apply for that KPI.

the latter part of your suggestion doesn't apply in this case so cannot use that.

Not applicable

You could probably handle that using a macro. There are Invisible and Enable properties to handle this (see the API Guide). Unfortunately, I haven't found it very easy to manipulate expressions using the API. The expressions are stored in an array, so you kind of need to know which one you want to manipulate. If it will always be the third expression you will be disabling, that may make things easier.

Boorgura mentioned using the Conditional Show of a chart and I don't think that should be overlooked. In situations like this, I'll often create two similar charts, but only show one at a time. In your case, you could make a three expression version and a two expression version. Then base the show on whether or not there is a third expression. You can modify the layout, so that the charts are in the same space. The transition between charts usually ends up being pretty seemless.

avastani
Partner - Creator III
Partner - Creator III
Author

that should do it then. macro, but if only i could avoid the 2 chart version which is what i have right now.

Not applicable

Here is a macro that should handle it (it disables and enables the third expression only):

Sub HideThird
set chart = ActiveDocument.GetSheetObject("CH01")
set cp = chart.GetProperties
set expr = cp.Expressions.Item(2).Item(0).Data.ExpressionData
expr.Enable = false
chart.SetProperties cp
End Sub
Sub ShowThird
set chart = ActiveDocument.GetSheetObject("CH01")
set cp = chart.GetProperties
set expr = cp.Expressions.Item(2).Item(0).Data.ExpressionData
expr.Enable = true
chart.SetProperties cp
End Sub


You'll probably need another macro set up for the OnSelect event of your KPI fields. In that macro, put your logic to determine whether the third expression should be shown and then call the corresponding Sub.

Not applicable

We ran into a similar issue. You can have null expression and not have expression displayed in the legend. I've attached a sample qvw that does what you're looking for.

Also, QlikView will not display anything if the first expression is null so the attached qvw has dummy hidden/invisible expression that always returns a value. If the first expression is never null then you don't need the hidden expression.

avastani
Partner - Creator III
Partner - Creator III
Author

Excellent. That is what I am looking for.