Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Set Analysis with "OR"

Simple problem, hopefully simple solution.

I have a sales table, each sale has two salespeople. Using set analysis the equation for one salesperson is something like

sum({< Salesperson1 = {"$(=getfieldselections(SalesPerson))"} SalesAmount)

That part works fine. However I'd like to do something like

sum({< Salesperson1 = {"$(=getfieldselections(SalesPerson))"} OR Salesperson2 = {"$(=getfieldselections(SalesPerson))"} SalesAmount)

Any suggestions on the syntax to make the "OR" work?

Thanks, Dave.

1 Solution

Accepted Solutions
erichshiino
Partner - Master
Partner - Master

You can create a union the the sets

sum({< Salesperson1 = {"$(=getfieldselections(SalesPerson))"} >+< Salesperson2 = {"$(=getfieldselections(SalesPerson))"} >} SalesAmount)

This way you will not count a sale twice (if salesperson1 and 2 are in SalesPerson)

You can also try to use p() function:

sum({< Salesperson1 =p(SalesPerson) >+< Salesperson2 =p(SalesPerson) >} SalesAmount)

View solution in original post

4 Replies
vincent_ardiet
Specialist
Specialist

You can try this :

sum({< Salesperson1 = {"$(=getfieldselections(SalesPerson))"}>} SalesAmount) + sum({< Salesperson2 = {"$(=getfieldselections(SalesPerson))"}>} SalesAmount)

Regards,

Vincent

erichshiino
Partner - Master
Partner - Master

You can create a union the the sets

sum({< Salesperson1 = {"$(=getfieldselections(SalesPerson))"} >+< Salesperson2 = {"$(=getfieldselections(SalesPerson))"} >} SalesAmount)

This way you will not count a sale twice (if salesperson1 and 2 are in SalesPerson)

You can also try to use p() function:

sum({< Salesperson1 =p(SalesPerson) >+< Salesperson2 =p(SalesPerson) >} SalesAmount)

Not applicable
Author

Thanks Erick, I just happened to stumble into the answer as well. This is the perfect result.

Dave

Not applicable
Author

Hi Vincent -

Thanks for the quick reply, however what happens with your solution is that you are actually doubling the result in the event both Salesperson1 and Salesperson2 are the same person. You effectively are creating an "And" statement, not using the exclusion benefits of an "Or" statement.

Thanks, Dave