Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Help with combining Bookmark and exclude within Set Analysis

I have an expression defined as below in straight table -

sum({FRA_BEL_1} AM_NET_CVA_ASGN_DELTA*YTDFlag) +
sum({FRA_BEL_2} AM_NET_CVA_ASGN_DELTA*YTDFlag) +
sum({FRA_BEL_3} AM_NET_CVA_ASGN_DELTA*YTDFlag)

The expression uses bookmarks within set analysis. Now I want to exclude something throughout this calculation. So I am trying something like below

sum({FRA_BEL_1}, {$<~SECTOR_L1_3_NM = {"HEDGE FUNDS"}>} AM_NET_CVA_ASGN_DELTA*YTDFlag) +
sum({FRA_BEL_2}, {$<~SECTOR_L1_3_NM = {"HEDGE FUNDS"}>} AM_NET_CVA_ASGN_DELTA*YTDFlag) +
sum({FRA_BEL_3}, {$<~SECTOR_L1_3_NM = {"HEDGE FUNDS"}>} AM_NET_CVA_ASGN_DELTA*YTDFlag)

This obviously results as an error in expression. Is there a way I could combine bookmark and exclude one subset of data within a single set analysis?

Other alternative I was thinking was to join Sector information with actual data and add flag for each row to determine whether that row is HEDGE FUNDS or not. And use that flag in above calculation..

Appreciate any help... thanks!

1 Reply
Not applicable
Author

Try to use Set Operations:

Set Operators

Several set operators that can be used in set expressions exist. All set operators use sets as operands, as described above, and return a set as result.

+ Union. This binary operation returns a set consisting of the records that belong to any of the two set operands.

Exclusion. This binary operation returns a set of the records that belong to the first but not the other of the two set operands. Also, when used as a unary operator, it returns the complement set. -

* Intersection. This binary operation returns a set consisting of the records that belong to both of the two set operands.

/ Symmetric difference (XOR). This binary operation returns a set consisting of the records that belong to either, but not both of the two set operands.

The order of precedence is 1) Unary minus (complement), 2) Intersection and Symmetric difference, and 3) Union and Exclusion. Within a group, the expression is evaluated from left to right. Alternative orders can be defined by standard brackets, which may be necessary since the set operators do not commute, e.g. A+(B-C) is different from (A+B)-C which in turn is different from (A-C)+B.

Examples:

sum( {1-$} Sales )
returns sales for everything excluded by the current selection.

sum( {$*BM01} Sales )
returns sales for the intersection between the current selection and bookmark BM01.

sum( {-($+BM01)} Sales )
returns sales excluded by current selection and bookmark BM01.

Note
The use of set operators in combination with basic aggregation expressions involving fields from multiple QlikView tables may cause unpredictable results and should be avoided. E.g. if Quantity and Price are fields from different tables, then the expression sum({$*BM01}Quantity*Price) should be avoided.