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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Anonymous
Not applicable

Replacing NOW() with blank dates to calculate days difference

Hi All,

I am trying to calculate the days difference between two dates e.g. create and resolved some tickets are not resolved hence the dates are blank so to handle that i created "Resolved 2" however i use this in the "Incident Age 2" formula its given me wierd result (see below) not sure why. For the dates which are not blank the result is correct. What am i doing wrong? 

NOTE: i cannot use DATEDIFF because it gives output in integer and i need it in float.
 
Formula to handle blanks
Resolved 2 = IF(vw_incident[resolved_at]=BLANK(),NOW(),vw_incident[resolved_at])
 
Formula to calculate age
Incident Age 2 = IF(MIN(vw_incident[resolved_at])=BLANK(),1* [Resolved2]-MIN(vw_incident[create_date]),1*
MIN(vw_incident[resolved_at])-MIN(vw_incident[create_date]))
 
Output:
shariqjoy_New_0-1604871465145.png

 

1 ACCEPTED SOLUTION
mahoneypat
Microsoft Employee
Microsoft Employee

Note you can use DATEDIFF to return the result in hours or minutes too, and then divide by 24, etc. to get days in decimal form.  You could also use your Resolved 2 expression in a variable and use that in your Age measure (instead of a separate measure).

 

Regards,

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


View solution in original post

5 REPLIES 5
mahoneypat
Microsoft Employee
Microsoft Employee

Note you can use DATEDIFF to return the result in hours or minutes too, and then divide by 24, etc. to get days in decimal form.  You could also use your Resolved 2 expression in a variable and use that in your Age measure (instead of a separate measure).

 

Regards,

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


Anonymous
Not applicable

@mahoneypat  i just noticed a slight difference in the result , please see below. The result for the below example should 8.95 but with our calculation its coming up 8.96 what could be wrong ?

 

shariqjoy_0-1604927091376.png

 

 

Looks like a rounding error.  Maybe return MINUTES in the DATEDIFF instead?

Regards,

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


Anonymous
Not applicable

@mahoneypat  i returned it in SECONDS and then divided by /24/60/60 to convert it in days and it solved the issue.

Anonymous
Not applicable

@mahoneypat  thanks for this, it was the simplest solution and it worked for me. Kudos to you.

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.