Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Datediff formula help!

Can someone help me with setting up a datediff formula or some other that can be used in this case.  I have a column which have a start date when a project starts. You register that with a app...
  • Anonymous's avatar
    Anonymous
    7 years ago

    Hi Anonymous If I understood you somewhat correct this is what I would do:

     

    For the COMPLETED PROJECT DAYS: If you only want to display values for completed projects and have blank cells for ongoing projects do the following: 

     

     

    IF(ISBLANK(TableX[Finished]);" ";DATEDIFF(TableX[Started];TableX[Finished];DAY))

    This ignores ongiong projects.

     

     

    For the ONGOING DAYS column: if you want the number of days for ongiong projects and ignore finished use the following

     

    IF(ISBLANK(TableX[Finished]);DATEDIFF(TableX[Started];Today();DAY);" ")

     

     

    My own recommendation: 

    personally I would have went with a column for the number of days for every project (finished and ongoing) and then have a column to indicated if the project is finished or ongoing. In the order I've mentioned the columns would look like this

     

     

    IF(ISBLANK(TableX[Finished]);DATEDIFF(TableX[Started];Today();DAY);DATEDIFF(TableX[Started];TableX[Finished];DAY))
    IF(ISBLANK(TableX[Finished]);"Ongoing";"Finished")

    This'll also make it easier when displaying a slicer for viewing projects in the report. 

     

     

  • Anonymous's avatar
    Anonymous
    7 years ago

    Anonymous as you hinted it it's very similar in fact it's the same function you need to use as I put in the last part of my other message. The following

     

    IF(ISBLANK(TableX[Finished]);DATEDIFF(TableX[Started];Today();DAY);DATEDIFF(TableX[Started];TableX[Finished];DAY))

    The function evaluates if the cell in the stop date column is empty (=Project is ongoing) or not and uses the appropriate calculation based on this. 

     

    Hope it helps.