Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Equation that only responds to selections in one field?

Hi all -

I have a simple SUM equation that I would like to only respond to selections in two fields - Country and Year - but otherwise be bound to the parameters I have in the set analysis.  Right now it looks like this;

SUM({<[Finance Type]={'GDP'}>}Amounts)

So what I would like is for it to respond to Country and Year, but only return values from the field Finance Type = 'GDP' and not respond to selections in any other fields.  Any assistance?

1 Solution

Accepted Solutions
swuehl
MVP
MVP

Try this:


SUM({1<[Finance Type]={'GDP'}, Country = $::Country, Year = $::Year>} Amounts)

View solution in original post

7 Replies
swuehl
MVP
MVP

Try this:


SUM({1<[Finance Type]={'GDP'}, Country = $::Country, Year = $::Year>} Amounts)

Not applicable
Author

Double-EDIT: Ignore my previous edit.  This was correct, I had a typo when I pasted it. Could you explain to me the syntax of the things you have added (1, the $ and ::)?

swuehl
MVP
MVP

1 is stating the set identifier for global state with no selections / filtering.

SUM({1} Amounts) will just return the total sum of Amounts, not considering any selections.

Then I added set modifiers on top of that (within the <...>):

[Finance Typ] = {'GDP'}            Apply a selection of 'GDP' in field Finance Typ

Country = $::Country                Apply the selection of field Country in default selection state $ to field Country

Year = $::Year                         Apply the selection of field Year in default selection state $ to field Year

Use of $:: may not be mandatory, I use to explicitely state the state I want to read selections from.

swuehl
MVP
MVP

Could you post a small sample QVW? And what you expect to see when selecting certain values?

Not applicable
Author

See above - you were correct in the first response, I just had a typo when I pasted it.

Not applicable
Author

I guess I'm not really understanding what $:: does still.  What is it doing when you define the Country selection as $::Country?

swuehl
MVP
MVP

The :: is a so called scope operator, it just tells QV which state to look at when you referencing a field.

I am not sure how firm you are with set expression or alternate states, the $ references the current selection state, the state of current user selections e.g. in list boxes or charts. Maybe you can think of

Year = $::Year

like copying the user selections in a field Year list box to the internal state used for the aggregation (which is then a mixture of the full records set identifier 1 and the Year selections)

[Plus modifications in Type and Country]

Note sure if this clarifies anything, just play around and you will learn how it works.