Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
erric3210
Creator
Creator

getfieldselections & getselectedcount not working with Subfield and concat functions

Hi Community,

I've a requirement to show my selections in a table box using getfieldselections & getselectedcount.

I'm trying with al possible solutions but no luck till now.

I'm using Link Tables approach

My Script:

Table1:
LOAD
Date_New AS Date_New1,
Category AS Category1,
Account As Account1,
Date_New&'#'&Category&'#'&Account As key,
Names,
'Table1' AS Table_Flag1
FROM ........../Table1;

Table2:
LOAD
Date_New AS Date_New2,
Category AS Category2,
Account As Account2,
Date_New&'#'&Category&'#'&Account As key,
Net_Amount,
Budget,
'Table2' AS Table_Flag2
FROM ........../Table2;

 

The above 2 tables are used in 2 different sheets and I want one field selection to applicable on other sheet so that's why I have used Subfield function on Key field.

But when I'm using getfieldselections & getselectedcount on subfield function then the expression is not working.

It is returning null. See this:

Getselectedcount(concat(Distinct subfield(key,'#',1),','))

or,

Getfieldselections(concat(Distinct subfield(key,'#',1),','))

What I'm missing here. I've tried with concat Distinct also but still it's not working.

I've shared the sample data for my requirement. Also, suggest whether I'm using the right approach by linking 2 tables or not. Should I go with some other modeling approach like creating a link model or concatenated model.

Please see the below snapshot.

Sample Requirement.PNG

 

Need help on my requirement.

 

regards,

Eric

Labels (1)
3 Replies
Or
MVP
MVP

Could you explain what the exact problem / error is? In your screen capture, it looks like the function is returning the correct value.

erric3210
Creator
Creator
Author

Hi Or,

Thanks for replying.

When I use getselectedcount() or Getfieldselections() then the expression is not working.

It is returning null. See this:

Getselectedcount(concat(Distinct subfield(key,'#',1),','))

or,

Getfieldselections(concat(Distinct subfield(key,'#',1),','))

Or
MVP
MVP

GetSelectedCount() or GetFieldSelections() only work on fields. You can't use these functions on a text string, which is what you get when you use concat(). You would have to pre-separate your values into subfields at the script level and use those fields, or concatenate the full fields and then break up the result into subfields (which would be quite tricky and would likely require changing the way your key field is structured).