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

Announcements
Write Table now available in Qlik Cloud Analytics: Read Blog
cancel
Showing results for 
Search instead for 
Did you mean: 
baylor2016
Creator
Creator

How to get the patients' city at the given date?

Hi,

I am trying to get the summary of patients' city at a given date. The sample data is like this. I used the CITY as dimension and the following as my expression. It always return 4 records instead of 3. It looks like my expression does not exclude the previous cities. Please advice.

Thanks. Sample project attached.

=count(

{

<

YearMonth,

StartDate={"$(='<=' & Date(selectedDate))"},

PAT_ID=P({<

YearMonth,

StartDate={'=MAX(StartDate)'}>} PAT_ID)

>}

PAT_ID

)

     

PAT_IDCITYStartDateEnddateZIP
1HOUSTON5/31/201177008
2HOUSTON1/25/200910/9/200977071
2LA PORTE5/11/200912/29/201077571
3HOUSTON3/15/20094/1/200977265
3HOUSTON12/1/201677088
3ROSHARON3/26/20105/22/201277583

Longmatch.

10 Replies
vvvvvvizard
Partner - Specialist
Partner - Specialist

=count(

{

<

City={*}-{'ROSHARON'}, 

YearMonth,

StartDate={"$(='<=' & Date(selectedDate))"},

PAT_ID=P({<

YearMonth,

StartDate={'=MAX(StartDate)'}>} PAT_ID)

>}

PAT_ID

)

baylor2016
Creator
Creator
Author

Hard-code is not a solution for this problem. Thanks

tamilarasu
Champion
Champion

Hi Haijunw,

Try this,

=count(

{<

  YearMonth,

   StartDate={"$(='<=' & Date(selectedDate))"},

   PAT_ID=P({<

   YearMonth,

   StartDate={"$(=MAX(StartDate))"}>} PAT_ID)

>}

PAT_ID

)

baylor2016
Creator
Creator
Author

Not working. From other posts, I understand that the Max(StartDate) is only evaluated once. So we cannot get last city for each pat_id by using max(startdate).

tamilarasu
Champion
Champion

I am a bit unclear. What is your expected result? Which cities you should see?

baylor2016
Creator
Creator
Author

I would like to know where the patients are at a given date. In my example, if the selected date is 12/31/2016, then expected results is HOUSTON (2) and LA PORTE(1). If the selected data is 11/30/2016, the results should be HOUSTON(1) LA PORTE(1) and ROSHARON(1).  Thanks.

Anonymous
Not applicable

Hi,

Can you please explain the logic behind how you get Houston and La Porte for 12/31/2016.

Anil_Babu_Samineni

I don't have access your application, Perhaps this?

=count({<CITY = P({<CITY = {$(=Concat(Chr(39) & GetFieldSelections(CITY, ',', Chr(39)), ','))}>} CITY),YearMonth,StartDate={"$(='<=' & Date(selectedDate))"}, PAT_ID=P({<YearMonth,StartDate={'=MAX(StartDate)'}>} PAT_ID)>}PAT_ID)

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
baylor2016
Creator
Creator
Author

Not working.

What is the logic for CITY = P({<CITY = {$(=Concat(Chr(39) & GetFieldSelections(CITY, ',', Chr(39)), ','))}>} CITY)?

Can we get the different max(startdate) for each pat_id in set analysis?

Thanks