Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

vinay_bangari
Valued Contributor III

how to dynamically hide and enable a measure or dimension in chart

Hi ,

Sorry to ask to many basic questions. haven't gone through the training..

In qlikview we can dynamically hide and enable expression and dimension in the chart with button action or listbox selection. How can i do the same in Qliksense. i know we cannot create variables and buttons. Is there any better approach and also it would be more helpful if anyone shares any sample document. Can we conditionally hide and enable a object in Qlik sense.

1 Solution

Accepted Solutions
vinay_bangari
Valued Contributor III

Re: how to dynamically hide and enable a measure or dimension in chart

One of my colleague helped me on this. Wanted to post because there could be people like me...

Modify your script like this:

Define a table with the field names that you wish to select for your chart (it can be an inline table or any other type of table.)

Set HidePrefix accordingly

Create a variable to hold the Current Primary Dimension.  (It will only have a value if a value is selected.)

SET HidePrefix='_' ;

PrimaryDimension:

Load * Inline [

_PrimaryDimension

Division

Invoice Year

];

LET vCurrentPrimaryDimension = '=$(GetCurrentField(_PrimaryDimension))';

Modify your GUI like this:

Add a listbox

Set the Field function as:

=[_PrimaryDimension]

Title value as:

Select Dimension

Add a Chart:

Define the Dimension of your Chart to be:

Field function:

=[$(=_PrimaryDimension)]

Label

(leave it blank)  Unfortunately, the label does not allow a function, so it cannot be variable

Set the Title of your chart to be:

='$(=_PrimaryDimension)'

(Optional) And the Footnote of your chart to be:

='$(=_PrimaryDimension)'

And i don't the answer whether we can hide and enable a chart.

9 Replies
MVP
MVP

Re: how to dynamically hide and enable a measure or dimension in chart

May be create an Inline table and control the dimensions based on the inline table dimension using GetFieldSelections()

vinay_bangari
Valued Contributor III

Re: how to dynamically hide and enable a measure or dimension in chart

That is a good idea.i will try that and let you know. One more thing we cannot hide and enable charts in Qlik sense? Do we

vinay_bangari
Valued Contributor III

Re: how to dynamically hide and enable a measure or dimension in chart

One of my colleague helped me on this. Wanted to post because there could be people like me...

Modify your script like this:

Define a table with the field names that you wish to select for your chart (it can be an inline table or any other type of table.)

Set HidePrefix accordingly

Create a variable to hold the Current Primary Dimension.  (It will only have a value if a value is selected.)

SET HidePrefix='_' ;

PrimaryDimension:

Load * Inline [

_PrimaryDimension

Division

Invoice Year

];

LET vCurrentPrimaryDimension = '=$(GetCurrentField(_PrimaryDimension))';

Modify your GUI like this:

Add a listbox

Set the Field function as:

=[_PrimaryDimension]

Title value as:

Select Dimension

Add a Chart:

Define the Dimension of your Chart to be:

Field function:

=[$(=_PrimaryDimension)]

Label

(leave it blank)  Unfortunately, the label does not allow a function, so it cannot be variable

Set the Title of your chart to be:

='$(=_PrimaryDimension)'

(Optional) And the Footnote of your chart to be:

='$(=_PrimaryDimension)'

And i don't the answer whether we can hide and enable a chart.

vinay_bangari
Valued Contributor III

Re: how to dynamically hide and enable a measure or dimension in chart

Yaar Sunny do you know how to define that Getfeildselections in the front end in the dimension.

MVP
MVP

Re: how to dynamically hide and enable a measure or dimension in chart

Kya matlab Vinay bhai? Can you share an example of what you trying to do?

vinay_bangari
Valued Contributor III

Re: how to dynamically hide and enable a measure or dimension in chart

Sunny the solution which i have provided above is working but the label is showing a variable name not the selected field name. But i want to try your GetFieldSelections() option too.. for example in the script i have defined the inline table as below:

PrimaryDimension:

Load * Inline [

_PrimaryDimension

DIVISION_NAME

SalesRepName

Sales Channel

Delivery State

OCUSMA State

];

when i take the _PrimaryDimension in the filter pane. And now i want the same field to be displayed in the chart too..Let me know if that makes sense. otherwise i will post you in some more detail.

phaneendra_kunc
Valued Contributor III

Re: how to dynamically hide and enable a measure or dimension in chart

one thing you wont have with this approach is "Always One selected" if user doesnt pick anything you will error in the chart.

i am using an list box extension for my on the fly metrics/dimension selections.

Qlik Sense List Box Extension

MVP
MVP

Re: how to dynamically hide and enable a measure or dimension in chart

Well, the idea you have below is what I wanted to propose also. GetFieldSelections was an idea to restrict measures and dimensions. But I have very limited knowledge of how to do it in Qlik Sense. I guess Phani might be able to shed more light on that

vinay_bangari
Valued Contributor III

Re: how to dynamically hide and enable a measure or dimension in chart

Hey super raa...