Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

Not applicable

getfieldselections with multiple values

Hi everyone.

I'm currently trying to use the function getfield slections in order to filter a table based on a selected value in a filter box.

The expression I'm currently using is the following:

=sum(if(recorddate=getfieldselections(selecteddate), revenues))

The problem arises when I select two or more date in the filter box: the if function finds no corresponding value.

How can I deal with this issue? Thanks.

Please see attachments for further details.

Additional info: selectedddate and recorddate are not linked together - there's no association between them.

Tags (2)
1 Solution

Accepted Solutions
MVP
MVP

Re: getfieldselections with multiple values

It doesn't matter if they are from two different sources. Have you checked if both the fields are read as dates by QlikView? This isn't going to work if one is text and other is date.

10 Replies
ahaahaaha
Honored Contributor

Re: getfieldselections with multiple values

Hi

Try

=sum(if(recorddate=Chr(39)&GetFieldSelections(selecteddate, Chr(39)&','&Chr(39))&Chr(39), revenues))

Not applicable

Re: getfieldselections with multiple values

Hi Andrey. Sorry, but expression does not not do thhe job. I'm not able to see revenues even for a single selection now.

MVP
MVP

Re: getfieldselections with multiple values

Try this

=Sum({<recorddate = P(selecteddate)>} revenues)

mov
Esteemed Contributor III

Re: getfieldselections with multiple values

did you try

=sum(if(recorddate=selecteddate, revenues))

or

sum({<recorddate=P(selecteddate)>} revenues)

Not applicable

Re: getfieldselections with multiple values

even worse this way round..

Cattura.PNG

Not applicable

Re: getfieldselections with multiple values

Same as Sunny solution.

Please note that selected date and recorddate are not connected. That's why I was using the getfieldselections function.

MVP
MVP

Re: getfieldselections with multiple values

It doesn't matter if they are from two different sources. Have you checked if both the fields are read as dates by QlikView? This isn't going to work if one is text and other is date.

kvanandan1
Contributor

Re: getfieldselections with multiple values

Hi Gabriel,

Can you please try

=sum({<recorddate={ $(=chr(39) & concat(distinct  seelcteddate,chr(39)&chr(44)&chr(39)) & Chr(39)) } >} revenues)


Thanks.

mov
Esteemed Contributor III

Re: getfieldselections with multiple values

Both my expressions are exactly for the situation when the two dates are not associated.
The most likely reason it doesn't work, as stalwar1‌ mentioned, that the fields are not in the same format.  On your screenshot, the MonthYear field is left-aligned, as text aligned by default.  Whatever expression you choose, make sure that the format is the same.  You can do it within the expressions, but it makes more sense to fix it on the script level.