Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Fields with selections

Hi,

I have a list of field 'Field1', 'Field2', 'Field3', 'Field4', 'Field5'.

I want to compare this list of fields to current selections in order to generate an output with fields present in my list  in which a selection is currently made.

Does anyone would have an idea to achieve this ?

5 Replies
Peter_Cammaert
Partner - Champion III
Partner - Champion III

I'm not sure I understand what you're after.

If you want a dynamic table with expressions that can be selected from a separate list, have a look at the following example.

Peter

Gysbert_Wassenaar

I don't understand why you can't use a Current Selections Box object. But if you want an alternative have a look at the attached example.


talk is cheap, supply exceeds demand
Not applicable
Author

Hi,

Thank you for your response.

Here are more details on my problem : I have a master calendar with about 100 fields.

In a table, i have to display the price for the current month, the price for the next month and the price for the previous month.

My table must be independant from selections on a week, a commercial event, a particular day.

I currently create dynamically a set analysis with all the fields of my calendar except the month, but in order to ameliorate my formula I would like to have only the calendar fields present in active selections.

Gysbert_Wassenaar

So, If I understand you correctly you want a string that's a list of the fields in which selections are made?

Well, one way is to create a variable per field that returns the field name if there are selections in the field. Then concatenate all those variables into one string. The variables can be generated in the script:

SET _vFList ='';

FOR i = 0 to NoOfTables()-1;

LET vTable = TableName($(i));

FOR j = 0 to NoOfFields('$(vTable)')-1;

  vField=FieldName($(j),'$(vTable)');

  vVarName=replace('$(vField)',' ','_');

  SET _v$(vVarName) = =if(getselectedcount([$(vField)]),'$(vField),');

  SET _vFList = $(_vFList) & _v$(vVarName);

NEXT j;

NEXT i;

LET _vFList = right('$(_vFList)',len('$(_vFList)')-1 );

The last variable _vFList should return the list of fields when you dollar-expand it in a sheet object: $(_vFList). See attached example.

There may be an easier way, but I haven't found it yet. Maybe a real pro knows how to do this more efficiently.


talk is cheap, supply exceeds demand
dvasseur
Partner - Creator III
Partner - Creator III

Hi,

I had the same issue and could find a good solution. So I ended in listing all my fields (automatically through variables of course 😉 ) and, to my surprise, the performance was still very good, event with 100 fields.

But I'd love to have a proper answer on this too !

Regards,

David