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

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Set Analysis based on field selection

Hi all,

Sorry if this has been covered before but....

If I 'hard code' a value into a set analysis expression:

aggr(sum({1<V.Machine={'EC140CL-110565'}>}[V.Visit Value]), V.Manufacturer, [V.Month and Year Received], [V.Month and Year Delivered])

then this returns the desired result. If I then select the value in a field 'Machine' and change it to:

aggr(sum({1<V.Machine=Machine>}[V.Visit Value]), V.Manufacturer, [V.Month and Year Received], [V.Month and Year Delivered])

then nothing is returned but this seems to be how its described in the manual:

...A simple case is a selection based on the selected values of another field, e.g. <Order-Date = DeliveryDate>. This modifier will take the selected values from DeliveryDate and apply those as a selection on OrderDate...

Is it because my data is alphanumeric - do I have to use 'concat' to create quoted strings of each possible (ie not specifically selected) value?

Thanks!

Gordon

4 Replies
Anonymous
Not applicable
Author

Gordon,
Probably concat is the best option. I'd use a variable defiened like this:
=chr(39)& concat(distinct Machine chr(39)&chr(44)&chr(39))&chr(39)
And, use the variable in set expression.
Or think of using P() in set expression for getting possible. I use it occasionally, but can't tell how it may look in your situation.

Not applicable
Author

Hi Michael,

Thank you for your reply.

I had set it up much as you suggested:

variable vMachines:
=concat({$<Del.Manufacturer*={"$(=GetFieldSelections(V.Manufacturer, Chr(34) & ',' & Chr(34)))"}>} distinct '"' & Machine & '"', ',')

where the user needs to select one value of V.Manufacturer (chart calculation conditioning/show has the expression 'len(V.Manufacturer) <> 0') and the chart expression is:

aggr(sum({1<V.Machine*={$(vMachines)}>} [V.Visit Value]), V.Manufacturer, [V.Month and Year Received], [V.Month and Year Delivered])

It would sure be easier if it could be done like the manual suggests <Order-Date = DeliveryDate> though!

Regards,

Gordon

PS! for anyone following this, the 'concat' will return all possible values whereas getfieldselections returns those actually selected. Also, I find that using variables often improves performance as these are 'pre-calculated' i.e the chart expression has the result already available for use and doesnt have to calculate them first.

Miguel_Angel_Baeyens


gordon.savage wrote:It would sure be easier if it could be done like the manual suggests <Order-Date = DeliveryDate> though!


According to Michael's suggestion, I'd use something like

aggr(sum({1<V.Machine=P(Machine)>}[V.Visit Value]), V.Manufacturer, [V.Month and Year Received], [V.Month and Year Delivered])


With the P() function. That will return all possible values for a field, but if a selection is done, then P() will return the selected values or the possible values given a selection, not all values (as Concat() function does). So in the example above, if there is one value selected in "Machine" field, V.Machine will take only that value. Besides, P() allow the use of set analysis as well.

It's the most similar to the Field1 = Field2 you mentioned.

Hope that makes sense.

Not applicable
Author

Ahh! Thanks Miguel - that certainly is a cleaner solution!

Regards the use of concat() though, it does effectively return just possible selections - only those explicitly or implicitily selected.

Regards,

Gordon