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

Sum IF with Distinct

I have the following columns of data:

1) Customer_ID

2) Service_Date

3) Service_Count

4) Location_Code

5) Service_ID

I need to add the Service_Count for Customer_IDs with DISTINCT Customer_ID & Service_Date, IF the Location_Code is 23.

How can I write an expression for this?

I originally had

Sum( If( Location_Code = '23', Service_Count, ))

Obviously this is incorrect, but did not know how to add the DISTINCT clause.

Any help is greatly appreciated.

1 Solution

Accepted Solutions
sunny_talwar

May be try this:

Sum({<Location_Code = {23}>} Aggr(Sum(DISTINCT {<Location_Code = {23}>} Service_Count), Customer_ID, Service_Date))

View solution in original post

3 Replies
sunny_talwar

May be try this:

Sum({<Location_Code = {23}>} Aggr(Sum(DISTINCT {<Location_Code = {23}>} Service_Count), Customer_ID, Service_Date))

Not applicable
Author

THank you, this worked perfectly.

sunny_talwar

Awesome