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

Selecting the same value in two fields - continued

Hi everyone,

I was recently given this awesome expression to sum Amounts for a value if it was present in either Field1 or Field2:

if(GetSelectedCount(Field1), sum({<Field1=p(Field1),Field2=>+<Field2=p(Field1),Field1=>}Amounts),

if(GetSelectedCount(Field2), sum({<Field2=p(Field2),Field1=>+<Field1=p(Field2),Field2=>}Amounts),sum(Amounts)))

However, I would like to create some variations on this. How do I write an expression that does the following:

- sum when the selected value is ONLY in Field1;

- sum when the selected value is ONLY in Field2;

- sum ONLY when the selected value is BOTH in Field1 and Field2.

Does anyone know how I can do this?

1 Solution

Accepted Solutions
jonathandienst
Partner - Champion III
Partner - Champion III

You might be able to achieve this by changing the + sign (union) to * for intersection (BOTH) and - for exclude, like this:

<Field1=p(Field1),Field2=>-<Field2=p(Field1),Field1=>

<Field2=p(Field2),Field1=>-<Field1=p(Field2),Field2=>

<Field2=p(Field2),Field1=>*<Field1=p(Field2),Field2=>


HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein

View solution in original post

2 Replies
jonathandienst
Partner - Champion III
Partner - Champion III

You might be able to achieve this by changing the + sign (union) to * for intersection (BOTH) and - for exclude, like this:

<Field1=p(Field1),Field2=>-<Field2=p(Field1),Field1=>

<Field2=p(Field2),Field1=>-<Field1=p(Field2),Field2=>

<Field2=p(Field2),Field1=>*<Field1=p(Field2),Field2=>


HTH

Jonathan

Logic will get you from a to b. Imagination will take you everywhere. - A Einstein
Not applicable
Author

It worked. Thank you!