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: 
ryaneverts
Contributor II
Contributor II

Dollar sign expansion and Set Analysis?

Hi Qlik Community,

I'm working on a set analysis issue, but am getting tripped up over some behavior with dollar sign expansion I can't seem to figure out.

As an example:

I have a field Reps which contains representative names.  Based on the selection of reps, I want to return a string with the names of the selected reps, like so:

=GetFieldSelections(Reps)

With reps Jerry A, Tom B, and Luke C selected, the text box I have added this expression to now shows Jerry A, Tom B, Luke C.  But, if I try to wrap this expression for evaluation like so:

=$(=GetFieldSelections(Reps))


I now get Error: Garbage after expression: "A", where I would expect that the text box would display the same information as before.

On a larger scale, what I need to accomplish is setting up a P function to get the current teams (field: CurrentTeam) for the selected representatives and returning this value for the set analysis.  The code currently looks more or less like this:

<CurrentTeam = P({<Reps={$(=GetFieldSelections(Reps))}>}CurrentTeam)>

It seems like I'm missing something fundamental here, community sanity check on how I'm approaching this would be appreciated.

1 Solution

Accepted Solutions
marcus_sommer

In general your approach looks good then getfieldselections() and p() return the selected field-values and don't need necessary wrapped with quotes. But I'm not sure if this worked if the values contain spaces or special chars. In this case you might need some kind of quote-wrapping like:

$(= chr(39) & getfieldselections(Reps, chr(39) & ',' & chr(39)) & chr(39))

or as alternatively with concat which could include further set analysis

$(= chr(39) & concat(distinct Reps, chr(39) & ',' & chr(39)) & chr(39))

but before check if p() is more tolerant:

<CurrentTeam = P({<Reps= p(Reps)}>} CurrentTeam)>

- Marcus

View solution in original post

3 Replies
marcus_sommer

In general your approach looks good then getfieldselections() and p() return the selected field-values and don't need necessary wrapped with quotes. But I'm not sure if this worked if the values contain spaces or special chars. In this case you might need some kind of quote-wrapping like:

$(= chr(39) & getfieldselections(Reps, chr(39) & ',' & chr(39)) & chr(39))

or as alternatively with concat which could include further set analysis

$(= chr(39) & concat(distinct Reps, chr(39) & ',' & chr(39)) & chr(39))

but before check if p() is more tolerant:

<CurrentTeam = P({<Reps= p(Reps)}>} CurrentTeam)>

- Marcus

ryaneverts
Contributor II
Contributor II
Author

Hi Marcus,

That's unfortunately the situation we're in, each Rep name may have one or more spaces, and may include hyphens and apostrophes (though that's been less of an issue in testing).

I'll try out the p and concat options and report back with my findings, that might do the trick.

-Ryan

ryaneverts
Contributor II
Contributor II
Author

Following up, the text data returned as expected when using:

<CurrentTeam = P({<Reps= p(Reps)}>} CurrentTeam)>


Since I don't trust the concat options to return as expected due to some unusual rep names, I think we'll go with this as the solution.


Thanks again for your assistance, Marcus!