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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
BoXiangWang
Contributor III
Contributor III

How to exclude union set analysis from original analysis

Hey QS experts,

 

I have this expression:

sum({<
[payroll_status]={"A"}, MonthEndInd={1},
[date_month.autoCalendar.Year]={"$(=$(vSelCurrentYear))"},
[date_month.autoCalendar.Month]={"$(=$(vSelCurrentMonth))"}>} leave_day)

 

Now I want to exclude a certain group based on two fields:

employee_class={'GS'}, region={'Region'}

 

How can I combine it back to the original set analysis?

Please remember, I want to remove the union group.

Instead of removing the whole 'GS' and 'Region', I want to keep some of the sub-groups.

For instance, in the employee_class I have A, B and GS, while in the region I have C and Region, and they are overlapped.

I knew we have union function in the set analysis but I don't know how to integrate them together.

The workaround I'm using now is the use two expression and subtract them...which is not convenient.

Any ideas appreciated! Thank you.

Labels (1)
1 Reply
diegozecchini
Specialist
Specialist

Hi! To exclude a specific subset within a Qlik Sense set analysis expression without entirely removing a whole field value, you can use the implicit exclusion by using a - (minus sign) and specify the subset conditions directly. Here’s how you can integrate it into your existing expression to filter out only the subset {employee_class={'GS'}, region={'Region'}} without removing all GS or all Region.


sum({
<
[payroll_status] = {"A"},
MonthEndInd = {1},
[date_month.autoCalendar.Year] = {"$(=$(vSelCurrentYear))"},
[date_month.autoCalendar.Month] = {"$(=$(vSelCurrentMonth))"},
employee_class -= {"GS"},
region -= {"Region"}
>
} leave_day)
In this structure:

-= will exclude only the specific subset from your results without removing all entries with GS in employee_class or Region in region.
Implicit Exclusion: By using -=, you specify the conditions you want to exclude from the set.
Explanation
The above expression will sum leave_day while meeting the following:

Filters for payroll_status as "A" and MonthEndInd as 1.
Matches the current year and month selections.
Excludes records where employee_class is exactly "GS" and region is exactly "Region" simultaneously, while retaining any other values in employee_class and region.


If you need to exclude a more complex subset, Qlik allows nested set expressions or combinations using * and +.

Hope it helps
Diego