Qlik Community

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How to pass a value from dashboard to variable definition?

Hi experts,

          I would like to pass a value from a user defined list box of the dashbouard to a variable definition in order to avoid designing multiple charts with only one parameter different. For example, I have a variable defined as count({$<Metric={1}, Intervention={0} >}HospitalAccountID), I hope I can pass different values obtained from list in the dashboard to Metrics such as CXR, Readmission, orderSet. In this way, I only need ONE chart instead of THREE charts on the dashboard.

Is this passible? Thanks

Longmatch.

1 Solution

Accepted Solutions
Jason_Michaelides
Luminary Alumni
Luminary Alumni

Yep, got it.

There are 2 ways of doing this:

  1. If the different possibilities for CXR, Readmission etc are not too many and not likely to change, then the simplest solution would be to create an expression for each possibility and use the conditional show feature introduced in v11 based on your listbox selection.
  2. If the different possibilities are large and/or likely to change frequently, then use a variable to dynamically build the required expression and evaluate that variable in the chart expression.

         

Detail for option 2:

Assuming you have a field called [Metric Option] in the data model (most likely a data island), create a variable, vExpression, with the following value:

='Count({' & Chr(36) & '<' & Only([Metric Option] & '={1}, Intervention={0}>} HospitalAccountID)'

Then, in the chart expression, use $(vExpression)

There may be a typo in the above - I haven't tested it.

Jason

View solution in original post

12 Replies
Jason_Michaelides
Luminary Alumni
Luminary Alumni

What version of QV are you using?

Are you saying that based on a user-selection you want your expression to change e.g.

count({$<Metric={CXR value}, Intervention={0} >}HospitalAccountID)

count({$<Metric={Readmission alue}, Intervention={0} >}HospitalAccountID)

count({$<Metric={Orderset value}, Intervention={0} >}HospitalAccountID)


?

Not applicable
Author

Thank you very much for your quick response.

I am using QV 11.

CXR, readmission and Orderset are from different columns in the database. What I really want is to replace Metrics with the value from dashboard such as CXR, readmission and orderset. Right now I am using count({$<CXR={1}, Intervention={0} >}HospitalAccountID) for CXR chart, I do not want to create another two charts for readmission and orderset.  I am hoping I stated my questions clearly this time. Thanks

Not applicable
Author

I think I might be able to create a new variable named selectedMetrics to link its value to a listbox created by inline coding and replace Metrics in the expression with this variable. Is this  the correct approach? Thanks.

Jason_Michaelides
Luminary Alumni
Luminary Alumni

Yep, got it.

There are 2 ways of doing this:

  1. If the different possibilities for CXR, Readmission etc are not too many and not likely to change, then the simplest solution would be to create an expression for each possibility and use the conditional show feature introduced in v11 based on your listbox selection.
  2. If the different possibilities are large and/or likely to change frequently, then use a variable to dynamically build the required expression and evaluate that variable in the chart expression.

         

Detail for option 2:

Assuming you have a field called [Metric Option] in the data model (most likely a data island), create a variable, vExpression, with the following value:

='Count({' & Chr(36) & '<' & Only([Metric Option] & '={1}, Intervention={0}>} HospitalAccountID)'

Then, in the chart expression, use $(vExpression)

There may be a typo in the above - I haven't tested it.

Jason

View solution in original post

Not applicable
Author

I will test the number 2 option later today.

Conditional show feature introduced in v11 is the feature I wanted to use but don't know how. Is there any tutorial or instructions how to use this wonderful new feature? Thanks.

Jason_Michaelides
Luminary Alumni
Luminary Alumni

It's really simple. Create the different expressions as normal.  Then tick the "Conditional box" and enter a boolean expression.  When the result of this expression is TRUE, the expression will display in the chart.

e.g.

Expression = count({$<CXR={1}, Intervention={0} >}HospitalAccountID)

Condition = Only([Metric Option]) = 'CXR'

Hope this helps,

Jason

Not applicable
Author

Thank you very much for your helps. My problem has been solved under your help. To make my dashboard more robust, I wanted to pass the value selected from listbox to the variable definition - the original question. I defined a variable v_testVariable as =sum(CXR), and it works fine. I would like to change the definition to =sum(only[%Metrics option]), it does not work even I selected CXR was selected. Any suggestions? Thanks

Jason_Michaelides
Luminary Alumni
Luminary Alumni

Can you post a sample of your app?

Not applicable
Author

Here is my sample. What I wanted to do it to replace CXR in expression definition, variable definition, chart title and legend with the item selected in Metrics listbox. In this way, I do not need create individual chart for each metrics. It will save a lot of dashboard space and it will be more efficient. Thanks