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

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Shivam22
Contributor II
Contributor II

Set Analysis with Or condition

Hi All,

I have a data set like below and i need create a textbox to count distinct ID where any of values from test1 to test4 is 1 and other textbox showing count with any of values from test1 to test4 is 0, without counting them twice.

For example - Count(any of values from test1 to test4 is 1) = 5

Count(any of values from test1 to test4 is 0) = 2

 

ID test1 test2 test2 test4
AAA 1 0 1 0
BBB 1 1 1 1
CCC 1 0 1 0
DDD 0 1 0 1
EEE 1 1 1 1
FFF 0 0 0 0
GGG 0 0 0 0

 

Can anyone pls help me understand how to achieve this?

 

Thanks in Advance

Labels (4)
3 Replies
Or
MVP
MVP

This would be a union, seemingly. 

{< test1 = {1} + test2 = {1} + test3 = {1} + test4 = {1} >}

https://help.qlik.com/en-US/sense/May2025/Subsystems/Hub/Content/Sense_Hub/ChartFunctions/SetAnalysi...

marksouzacosta

Hi @Shivam22 ,

You can also change your Load Script to facilitate the chart measure:

TestData:
Load 
    ID,
    test1,
    test2,
    test3,
    test4,
    If(RangeSum(test1,test2,test3,test4) = 0,0,1) AS CountFlag
Inline [
ID, test1, test2, test3, test4
AAA, 1, 0, 1, 0
BBB, 1, 1, 1, 1
CCC, 1, 0, 1, 0
DDD, 0, 1, 0, 1
EEE, 1, 1, 1, 1
FFF, 0, 0, 0, 0
GGG, 0, 0, 0, 0
];

 

The Measures will be like:

marksouzacosta_0-1761137652803.png

 

Regards,

Mark Costa

Read more at Data Voyagers - datavoyagers.net
Follow me on my LinkedIn | Know IPC Global at ipc-global.com

Chanty4u
MVP
MVP

Try this for any 1

=Count(DISTINCT {<ID = {"=Sum(test1+test2+test3+test4) > 0"}>} ID)

Try this for any 0

=Count(DISTINCT {<ID = {"=Sum(test1+test2+test3+test4) = 0"}>} ID)

 

 

Or you can try this way

=Count(DISTINCT If(test1 = 1 or test2 = 1 or test3 = 1 or test4 = 1, ID))

 

For all 0

=Count(DISTINCT If(test1 = 0 and test2 = 0 and test3 = 0 and test4 = 0, ID))