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

How to calculate number of days based on a condition?

Within an expression, I would like to calculate the number of days between two dates as follows:

Thus far:

=sum (Today()-"start_date")

works to provide the days between today and the start date (open date of a job), but I ONLY want this to calculate IF there is no current "end_date"

I would appreciate any help in discovering how to make this work,

Kind regards,

Mark

1 Solution

Accepted Solutions
sunny_talwar

May be like this:

=Sum(If(Len(Trim("end_date")) = 0, Today()-"start_date"))

or you can use a unique identifier field here:

=Sum({<UniqueIdentifierField = {"=Len(Trim("end_date")) = 0"}>} Today() - "start_date")

View solution in original post

5 Replies
sunny_talwar

May be like this:

=Sum(If(Len(Trim("end_date")) = 0, Today()-"start_date"))

or you can use a unique identifier field here:

=Sum({<UniqueIdentifierField = {"=Len(Trim("end_date")) = 0"}>} Today() - "start_date")

Not applicable
Author

Wow Sunny that was astonishingly quick and impressively first time success!

I noticed already that you have an amazing reputation for success – so very pleased to have your help – THANK YOU!

Have a great evening,

Kind regards,

Mark

sunny_talwar

I am glad to help Mark... Would you be able to point out which of the two expression worked for you?

Best,

Sunny

Not applicable
Author

Hi Sunny

I tried the first one and it worked, so I didn’t need to try the second one.

So I can identify the correct answer from your first reply, but not sure how to point out online the first answer you gave and not the second?

Thanks for your help indeed!

Kind regards,

Mark

sunny_talwar

I think your mention that the first expression worked should be good enough. or else you can repost a response where you can say that this is the expression which worked for you to make it explicit