Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results 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
MVP

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")

5 Replies
MVP

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

MVP

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

MVP

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

Community Browser