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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Count with date difference as condition

Hello!

Here is my sample data:

Capture.PNG

I want to count the records that fits the condition: Date B - Date A <= 180

I tried a number of expressions but none work:

  • count(distinct if((date([Date B])-date([Date A])) <= $(180),[ID]) >>  nothing is displayed?
  • count(distinct {$<[Date B] = { <=$(=<date([Date A]+180)) } >} [ID]) >>  counts all records (result = 20)
  • count(distinct {$<[Date B] = {" <=$(=<date([Date A]+180)) "} >} [02_Full_name]) >>  result = 0

Please help!

1 Solution

Accepted Solutions
marcus_sommer
MVP
MVP

Try:

count(if([Date B]-[Date A] <= 180, [ID])

- Marcus

View solution in original post

5 Replies
Chanty4u
MVP
MVP

count(distinct {$<date[Date B] = { <=$(=<date([Date A]+180)) } >} [ID]) >>

marcus_sommer
MVP
MVP

Try:

count(if([Date B]-[Date A] <= 180, [ID])

- Marcus

Not applicable
Author

This counts all records in the table.

Not applicable
Author

This works perfectly! How come I didn't think of this...

Thanks a lot Marcus!

Chanty4u
MVP
MVP

Hmmm