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: 
brucejensen
Contributor III
Contributor III

Text Object - display field based on current selections

Is there a way to have a text object display information based on what the current selections are? For example, say the user has selected Bldg 1 and Bldg 2. Can the text object then display the value from the Address field for Bldg 1 in text object 1 and the address field for Bldg 2 in Text Object 2? Then if the selections change, the values in the text objects change along with them. Thanks in advance for any assistance.

1 Solution

Accepted Solutions
jerem1234
Specialist II
Specialist II

Actually you might want to use:

=only({<Building={"$(=subfield(concat(Building, '|'), '|', 1))"}>}Address)

=only({<Building={"$(=subfield(concat(Building, '|'), '|', 2))"}>}Address)

The way concat sorts might cause a problem, it will sort on address, and not necessarily the order of buildings.

Hope this helps!

View solution in original post

8 Replies
Not applicable

Hi Jensen,

For a text object, you can use a function =GetCurrentSelections(FieldName). When selections are made to that specific field, the text will be displayed in the text object.

Thanks,

Sai

maxgro
MVP
MVP

from qlikview online help

getfieldselections ( FieldName [, ValueSep [, MaxValues]])

Returns a string with the current selections in a field.

ValueSep is the separator to be put between field values. The default is ', '.

Maxvalues is the maximum number of field values to be individually listed. When a larger number of values is selected the format 'x of y values' will be used instead. The default is 6.

Examples

getfieldselections ( Year )

getfieldselections ( Year, '; ' )

getfieldselections ( Year, '; ' , 10 )

getcurrentselections ([RecordSep [, TagSep [,ValueSep [, MaxValues]]]])

Returns a string with the current selections in the document.

RecordSep is the separator to be put between field records. The default is <CR><LF>.

TagSep is the separator to be put between the field name tag and the field values. The default is ': '.

ValueSep is the separator to be put between field values. The default is ', '.

Maxvalues is the maximum number of field values to be individually listed. When a larger number of values is selected the format 'x of y values' will be used instead. The default is 6.

Examples

getcurrentselections ( )

getcurrentselections ( chr(13)&chr(10) , ' = ' )

getcurrentselections ( chr(13)&chr(10) , ' : ' , ' ; ' )

getcurrentselections ( chr(13)&chr(10) , ' : ' , ' ; ' , 10 )

brucejensen
Contributor III
Contributor III
Author

Unfortunately, that doesn't seem to work in this case (returns a "-"). I think it is because the only field selected is the building name not the address. What I'm looking for is if one field is selected and has two values selected, the corresponding text object displays it's field value.

Current selections: Building Name: Bldg One, Bldg Two

Text object 1: Address for Bldg One

Text Object 2: Address for Bldg Two

brucejensen
Contributor III
Contributor III
Author

Unfortunately it doesn't seem to work, returns a "-". Could it be because the only selections are in the Building name field but what I want to display is in the address field which wasn't explicitely selected?

jerem1234
Specialist II
Specialist II

You can try something like:

=subfield(concat(distinct Address, '|'), '|', 1)

This will concatenate the Address according to your selections of Building (so only the addresses of building 1 and 2 should be there), then subfield will return the first address in the list. Also,

=subfield(concat(distinct Address, '|'), '|', 2)

should get the second address.

Hope this helps!

brucejensen
Contributor III
Contributor III
Author

Thanks I'm going to try that but one question. What is the 'I' in the expression?

jerem1234
Specialist II
Specialist II

Actually you might want to use:

=only({<Building={"$(=subfield(concat(Building, '|'), '|', 1))"}>}Address)

=only({<Building={"$(=subfield(concat(Building, '|'), '|', 2))"}>}Address)

The way concat sorts might cause a problem, it will sort on address, and not necessarily the order of buildings.

Hope this helps!

brucejensen
Contributor III
Contributor III
Author

Once again you've come through with an answer for me! Works great! Thanks!