Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
jwaligora
Creator II
Creator II

Removing 'subfields' from the result of GetCurrentSelections()

Hi,

I have a long list of fields that the user can filter on.

I need to expose the list of items with current selections, but the list must exclude 6 specific fields (exclusions are date fields: {Year,Quarter,Month,Week}, a field that determines which visualization is displayed in the graph, and a frozen field that's hidden from view for most users).

Due to our server implementation, I can't use macros.

With RegEx this would be a breeze, but I don't see that option, meanwhile trying to do this with string functions is cumbersome and results in crazy formula bloat, since the removals are being done sequentially, not in parallel.

What are my options / what am I missing?

Labels (1)
1 Solution

Accepted Solutions
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Understand. How about: 

=concat(
  if( not Match(
    SubField(
      SubField(GetCurrentSelections('|', ':', ',', 1000)
        ,'|'
        ,ValueLoop(1,SubStringCount(GetCurrentSelections('|', ':', ',', 1000),'|')+1)
      )
      ,':',1)
,'Year', 'Quarter', 'Month', 'Week')  // Excluded fields
      ,SubField(GetCurrentSelections('|', ':', ',', 1000)
        ,'|'
        ,ValueLoop(1,SubStringCount(GetCurrentSelections('|', ':', ',', 1000),'|')+1)
      )
    , null() // An Excluded field
  ) // End of if()
,chr(10)) // Concat separator

Sorry if the indentation is off. I have difficulty getting that right in this web editor.  

-Rob
http://masterssummit.com
http://qlikviewcookbook.com
http://www.easyqlik.com

View solution in original post

5 Replies
rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

How about just marking the fields as hidden?

Tag Fields Year,Quarter,Month,Week with '$hidden';

-Rob

 

jwaligora
Creator II
Creator II
Author

@rwunderlich Apologies for the delay. 

To the best of my understanding using tags configures fields at script level, thus globally at the front-end. 

The date fields are fundamental to the app and, in general, their selections should be exposed. I'm dealing with one specific graph where I show 'selections as a % of period total'. All this means is that if Month=July and Fruit=Apple then the calculation is:

count(distinct {$} ID) / count(distinct {<Fruit="*">}  ID) 

Except there are many (~20) selectable fields, not just Fruit (above is for conceptual purposes only; actual calc uses {1 < [DateFld]=$::[DateFld]>} in the denominator) . This is all good and dandy, until the users lose track of which fields they made selections in 🙂 .  To address this, I've been requested to provide an in-graph text blurb listing all the fields in which active selections exist (though not necessarily the selections themselves). Since selectable time fields (of which I have 4: year, quarter, month, week) are visible on the x-axis and don't play into the % calculation, they need to be excluded from said blurb. For all other purposes I want to keep date selections visible. 

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

Understand. How about: 

=concat(
  if( not Match(
    SubField(
      SubField(GetCurrentSelections('|', ':', ',', 1000)
        ,'|'
        ,ValueLoop(1,SubStringCount(GetCurrentSelections('|', ':', ',', 1000),'|')+1)
      )
      ,':',1)
,'Year', 'Quarter', 'Month', 'Week')  // Excluded fields
      ,SubField(GetCurrentSelections('|', ':', ',', 1000)
        ,'|'
        ,ValueLoop(1,SubStringCount(GetCurrentSelections('|', ':', ',', 1000),'|')+1)
      )
    , null() // An Excluded field
  ) // End of if()
,chr(10)) // Concat separator

Sorry if the indentation is off. I have difficulty getting that right in this web editor.  

-Rob
http://masterssummit.com
http://qlikviewcookbook.com
http://www.easyqlik.com

jwaligora
Creator II
Creator II
Author

@rwunderlich  Brilliant! I could hug you!!! ...but seeing as we're in the midst of the COVID-19 crisis, I'll just go and educate myself on the ValueLoop function 🙂

colinodonnel
Creator II
Creator II

Thanks Rob,

Hope you don't mind. Have tweaked the formula slightly to just show the field names. Huge thanks also to this post from Stefan. Solved: Is there an easy way to get the names of fields wi... - Qlik Community - 337293

=concat(
if (not match(
SubField(SubField(GetCurrentSelections('/'),'/', ValueLoop(1,vFieldNum,1)),':',1), 'Ratios'), // add to 'Ratios' for other fields to exclude
subfield(subfield(GetCurrentSelections('/'),'/',ValueLoop(1,vFieldNum,1)),':',2),
null())
,', ',ValueLoop(1,vFieldNum,1))