Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

DATEDIFF Calculation with Condition

Hi guys, I need a bit of help; please see the below example.

I need Project Duration (Age) Calculation based on the below condition

* If Project status is ''In Progress'''  or ''blank'' Calculate the difference between the ''Start Date'' and ''Today''

* If project status is ''Completed'', then calculate the difference between the "Start date'' and ''Construction date''

 

Project Name

Start Date

Construction  date

Status

Project duration

A

1/10/2020

6/8/2021

In Progress

 

B

5/6/2019

7/5/2020

Completed

 

C

7/5/2021

 

In Progress

 

D

8/5/2020

11/11/2021

In Progress

 

E

6/4/2021

 

In Progress

 

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

Write this calculated column formula

Duration = 1*(if(Data[Status]="Completed",[Contruction date]-[Start date],today()-[Start date]))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

6 REPLIES 6
mahoneypat
Microsoft Employee
Microsoft Employee

You can try a DAX calculated column with this expression

 

Duration =
IF(
    Table[Status] = "Completed",
    INT( Table[Construction Date] - Table[Start Date] ),
    INT( TODAY() - Table[Start Date] )
)

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Ashish_Mathur
Super User
Super User

Hi,

Write this calculated column formula

Duration = 1*(if(Data[Status]="Completed",[Contruction date]-[Start date],today()-[Start date]))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Sorry mate its not working

 

What does not working mean?  Show a screenshot.  Share the download link of your PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Sorry My Bad. All good now thanks

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.