Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
chrisghughes
Contributor II
Contributor II

Group By not working as I would expect

!

Hello -

I have the following table:

   

IDStart Dateactive_dateContact Date
4e1205d9-439a-48d2-bf86-49c9d413652f6/20/20135/24/20182/10/2018
4e1205d9-439a-48d2-bf86-49c9d413652f6/20/20135/24/20183/17/2018
4e1205d9-439a-48d2-bf86-49c9d413652f6/20/20135/24/20183/31/2018

I want to figure out how many times a contact occured before/after the start/active dates.

I have the following script

load

NoConcatenate

"ID",

sum(if("Contact Date" <= [Start Date],1,0)) as calls_before,

sum(if("Contact Date" > [Start Date] and "Contact Date" < "active_date",1,0)) as calls_after,

sum(if("Contact Date" > date("active_date"),1,0)) as calls_after_discharge,

count("Contact Date") as total_calls

resident res_contacts

group by "ID";

My expectation would be I would get a single row like this

    

IDcalls_beforecalls_aftercalls_after_dischargetotal_calls
4e1205d9-4 !39a-48d2-bf86-49c9d413652f0303

However, what I get is

    

IDcalls_beforecalls_aftercalls_after_dischargetotal_calls
4e1205d9-439a-48d2-bf86-49c9d413652f0909

I'm coming from a SQL background so this grouping behavior doesn't make sense to me.  I've made sure there is not assoications or linkings inside the application to make sure I'm not getting a cartesian product.  Even in Data Manager it shows the wrong values.

!

10 Replies
chrisghughes
Contributor II
Contributor II
Author

Ahhh...I understand now.  Qlik is joining it all together in the data model.  I was thinking too much in the SQL world