Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
bashar_f
Partner - Creator
Partner - Creator

Get a value based on a selection

I have a text object that displays a value from a variable, but I only want this value to show if a selection is made in list box, otherwise I want it to show 0.

Basically, I have a list box called semester with 2 values, 1301, 1401. the text object is called "Selected Semester" and it should show the result of the following expression only when a value is selected and for that specific value.

Count(EMPLID)

What should I write in the variable definition?

1 Solution

Accepted Solutions
ali_hijazi
Partner - Master II
Partner - Master II

then simply Count(EMPLID)

or in the definition of your variable write the following

=Count({<your_field={desired_value}>}EMPLID)>0

if this is not the case please elaborate more

I can walk on water when it freezes

View solution in original post

7 Replies
ali_hijazi
Partner - Master II
Partner - Master II

Use the function GetSelectedCount(fieldName)

I can walk on water when it freezes
bashar_f
Partner - Creator
Partner - Creator
Author

But that only gives me the number of selected fields. What I want to do is get the count of EMPLID where the semester is equal to the selected one from the list box.

ali_hijazi
Partner - Master II
Partner - Master II

then simply Count(EMPLID)

or in the definition of your variable write the following

=Count({<your_field={desired_value}>}EMPLID)>0

if this is not the case please elaborate more

I can walk on water when it freezes
bashar_f
Partner - Creator
Partner - Creator
Author

The code you wrote looks like what I want, but if only i can replace the "desired_value" with the selected value of the listbox, like if I selected 1401 from the listbox, I want 1401 to fill in the place of the desired value. The main thing here is that I want it to show 0 when nothing is selected and only act when something is selected.

ali_hijazi
Partner - Master II
Partner - Master II

then replace desired_value with Concat(distinct field_name,',')

I can walk on water when it freezes
ali_hijazi
Partner - Master II
Partner - Master II

use the following to check if a desired value is selected:

if(index(concat(distinct your_field,','),'your_desired_value')>0 ,1,0)

I can walk on water when it freezes
MK_QSL
MVP
MVP

='Selected Semester : '&IF(GetSelectedCount(semester)>0,Count(EMPID),0)