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: 
leale1997
Contributor III
Contributor III

Creating a Sumif formula based on Distinct field Values

I feel like this should be easy but I am just missing something.  I have tried aggr and sum and can't get this formula to work out correctly.

I have a data table that looks like the table below.  I would like to calculate the number of days a record that is not closed has been opened based on today's date and Distinct record ID's.  I have tried using variations of this formula:

sum(distinct if([Status]='Urgent' and isnull(DateClosed), today()-DateCreated, [RecordID]))

    

RecordIDDateCreatedStatusDateClosed
102/05/16Urgent02/25/16
201/01/17Routine
307/05/16Routine08/04/16
409/10/16Routine
502/10/16Urgent
601/06/17Routine
707/10/16Routine
809/15/16Routine
902/15/16Routine03/11/16
1001/11/17Routine
1107/15/16Routine
1209/20/16Routine11/04/16
1302/20/16Urgent
1401/16/17Routine
1507/20/16Urgent09/18/16
1609/25/16Urgent
1 Solution

Accepted Solutions
sunny_talwar

May be this:

Sum({<RecordID = {"=Len(Trim(DateClosed)) = 0"}, Status = {'Urgent'}>} Today() - DateCreated)

View solution in original post

8 Replies
sunny_talwar

May be this:

Sum({<RecordID = {"=Len(Trim(DateClosed)) = 0"}, Status = {'Urgent'}>} Today() - DateCreated)

leale1997
Contributor III
Contributor III
Author

Of course that's the answer ?#$%^&? LOL!  Thanks so much! 

leale1997
Contributor III
Contributor III
Author

Hi Sunny!

You were such a help with my last question. Wonder if you might field another. I would like to do the same thing except leave out the second criteria.

So I think it would look like this:

Sum({} Today() - DateCreated)

But it’s not working. What am I missing?

sunny_talwar

Leave which criteria? Closed Date or Status?

leale1997
Contributor III
Contributor III
Author

Leaving closed date is null.

But not considering Status as a criteria at all.

In other words, summing today()-datecreated for distinct record ids that do not have a populated dateclosed field.

The record id field may contain duplicates.

sunny_talwar

This

Sum({<RecordID = {"=Len(Trim(DateClosed)) = 0"}>} Today() - DateCreated)

leale1997
Contributor III
Contributor III
Author

Yes that worked! Thanks so much. I realize now I left out the ‘>’.

Way appreciate the assist. )

sunny_talwar

Sounds good