set analysis expression distinct count with multiple exclusions

1k Views Asked by At

I am trying to display a unique count of people. There are multiple programs that the people could have been in, and some of them I don't want to be counted (they were only on a wait list). I've searched the internet and tried an if statement as well as set analysis. I keep getting an answer that isn't accurate and isn't changed by my set analysis.

My current expression is: =count({<[ProgramName]-={'p2', 'p3', 'p4', 'p5'...}>} distinct [HumanName])

Here is an example of data assuming we are counting the number of distinct people in p1. The count of unique people would be 4:

sample data

In my real data I have 50 programs, I want to exclude about 20 and count distinct patients that are in the other 30. I've tried moving the distinct to the front of the expression (count(distinct( and that didn't affect my answer. When I remove the '-' making the expression include the listed programs, my answer remains the same. I tried using count({1-[ProgramName]={....} which also returns the same value.

Please help! I am new to set analysis although I'm familiar with other types of coding. Thank you :)

1

There are 1 best solutions below

0
On

The expression count({<[Program]-={'p2', 'p3', 'p4', 'p5'}>} distinct Name) should work. usualy when its not working mean something in your schema is wrong (or QV bug - can happen).

But you can try this expression (slower):

count(distinct if(match([Program],'p2', 'p3', 'p4', 'p5')=0,[Name]))