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: 
Not applicable

Passing variable field name into GetFieldSelections

I'm trying to create a custom Current Selections box for a particular set of date fields using a straight table and an expression that uses GetFieldSelections to return the values currently selected for each field.

In my load script I'm creating an inline table of fields that I want to show in this table, i.e.:

DateFilters:
LOAD * INLINE [
DateField, DateDescription
date1, Creation Date
date2, Closed Date
date3, Target Due Date
date4, Last Saved Date

];

So far I've managed to achieve the example straight table shown below using the following:

Dimensions:

DateField (hidden)

Expressions:

Date Field:

=only({1}DateDescription)

Current Filter:

=Replace(Replace(if(only({1}DateField)='date1',GetFieldSelections(date1),
if(only({1}DateField)='date2',GetFieldSelections(date2),
if(only({1}DateField)='date3',GetFieldSelections(date3),
if(only({1}DateField)='date4',GetFieldSelections(date4))))),'>=',''),'<=',' - ')

I want to avoid the nested IFs as I look to expand this elsewhere, and want to use the value in the DateField field inside the GetFieldSelections instead.

I have tried to achieve this using the following formula but get the error "Nested aggregation not allowed":

=GetFieldSelections(only({1}DateField))

Does anyone have any suggestions how I could use the field name stored in DateField inside the GetFieldSelections function?

(note - I'm using the only({1}) function since I want users to be able to click on each of the Date field rows and use this to apply date filters to each - so this ensures that all Date Fields are always shown in the table)

Thanks in advance.

3 Replies
sunny_talwar

May be try with Pick(Match(...))

Pick(Match(Only({1}DateField), 'date1', 'date2', 'date3', 'date4'), GetFieldSelections(date1), GetFieldSelections(date2), GetFieldSelections(date3), GetFieldSelections(date4))

Not applicable
Author

Thanks Sunny - but I'm hoping to avoid the hardcoding of date1, date2 etc altogether.

Since I have these values in the straight table (in the DateField field), I thought it should be possible to pass this value into the function, so all I need to maintain is my INLINE list of fields and descriptions on the load script - i.e. like =GetFieldSelections(only({1}DateField))

sunny_talwar

Unfortunately, I don't think this would be possible