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: 
Not applicable

complex set analysis with $ expansions

Hello,

we are trying to count the number of patients who receive >500 calories in their FIRST outpatient visit. Please see below for details... would appreciate any additions to Sushil's propsed solution.

Sushil posed the following solution:

=COUNT(DISTINCT {1<[DATE_OUTPT]={$(=Min([DATE_OUTPT]))},[OUTPT_CALDENS] = {">=500"}>} PAT_MRN_ID)

Thanks to Sushil for taking a stab at it...

so it doesn't seem to work.

here's some sample data:

PAT_MRN_ID     DATE_OUTPT     OUTPT_CALDENS

1                      jan 1                          300

1                      jan 7                          500

1                      jan-27                        700

2                      march 17                   650

2                      march 29                   400

2                      april 5                        325

2                      april 7                        800

3                      jan 10                        900

3                      jan 14                       1000

the correct count the above situation should be 2. There are two patients (ID 2 and 3 who receive >500 calories in their FIRST outpatient visit.

thank you SO much.

1 Solution

Accepted Solutions
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Try: =COUNT(DISTINCT {1<[DATE_OUTPT]={"=[DATE_OUTPT]=aggr(Min([DATE_OUTPT]),PAT_MRN_ID)" },[OUTPT_CALDENS] = {">=500"}>} PAT_MRN_ID)


talk is cheap, supply exceeds demand

View solution in original post

4 Replies
Gysbert_Wassenaar
Partner - Champion III
Partner - Champion III

Try: =COUNT(DISTINCT {1<[DATE_OUTPT]={"=[DATE_OUTPT]=aggr(Min([DATE_OUTPT]),PAT_MRN_ID)" },[OUTPT_CALDENS] = {">=500"}>} PAT_MRN_ID)


talk is cheap, supply exceeds demand
Not applicable
Author

=count(distinct{1<[DATE_OUTPT]={"$(=(date(min([DATE_OUTPT]))))"},[OUTPT_CALDENS]={">=500"}>}PAT_MRN_ID). You need to format min([Date_outpt]) so that it is the same of the format of date_outpt; if you do not it will take an integer value instead and no matches will be returned. If date() does not work consider MonthName().

Not applicable
Author

you are awesome!

can you explain to me a little bit of the theory behind what you did... I see you got rid of the $ exression but don't quite understand why the below works...

1<[DATE_OUTPT]={"=[DATE_OUTPT]=aggr(Min([DATE_OUTPT]),PAT_MRN_ID)" }

THANK YOU!

Not applicable
Author

also, I'll just add one other question:

it seems that this set picks up minimum dates where there is no Cal Dens associated with the date. I should have mentioned this before: there can be outpatient clinic dates where the patient receives no calories. So, we really want the minimum date, where cal dens is not blank-- and then count the ones greater than 500 from there.

sorry, forgot about that....