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
sdhn
Responsive Resident
Responsive Resident

Subtract two date columns in existing table

Hi All,

 

I am using Power Bi Desktop to develop report.

 

I need to add new column that computes elapsed time (Resolved date  – Created date = Elapsed)

 

Both columns are date. Do I need to write mesaure ?  etc 

 

Please advise 

 

Thanks 

1 ACCEPTED SOLUTION
sdhn
Responsive Resident
Responsive Resident

Elapsed =

VAR _diff = [Resolved Date Time] - [Created]

RETURN IF([Resolved Date Time]=BLANK(),0,_diff)

View solution in original post

8 REPLIES 8
sdhn
Responsive Resident
Responsive Resident

Elapsed =

VAR _diff = [Resolved Date Time] - [Created]

RETURN IF([Resolved Date Time]=BLANK(),0,_diff)

sdhn
Responsive Resident
Responsive Resident

Hi there,

 

thanks for your feedback. But I am not getting correct values.

 

1)  

Elapsed = CONVERT(MAX(Incident[Resolved Date Time])-MAX(Incident[Created]),DOUBLE)

sdhn_1-1637249735716.png

 

2)

Elapsed Diff = DATEDIFF(MAX(Incident[Created]),MAX(Incident[Resolved Date Time]),DAY)
 
sdhn_2-1637249828656.png

 

 

Thanks 

Yeah, I don't get that either with my table. 

 

From: 

Days Overdue = [Created Date] - [Due Date]
 
I get the error:  The value for 'Created Date' cannot be determined. Either the column doesn't exist, or there is no current row for this column.
VahidDM
Super User
Super User

Hi @sdhn 

 

Try this:

Elapsed = [Resolved date]-[Created date]

 

And change the new column data type to Whole number, Output:

 

VahidDM_0-1637219667036.png

 

 

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

Hi @sdhn , see the comment about about the error I get with that equation:  The value for 'Created Date' cannot be determined. Either the column doesn't exist, or there is no current row for this column.

sdhn
Responsive Resident
Responsive Resident

Hi there ,

 

Thanks 

This seems work. Only issue when we have no value in Resolved date time gives some numbers as:

 

sdhn_3-1637250405624.png

 

smpa01
Super User
Super User

@sdhn  you can create a measure like this

difference = DATEDIFF(MAX('Table'[Created date]),MAX('Table'[Resolved date]),DAY)

or  a calulated column

Column = CONVERT('Table'[Resolved date]-'Table'[Created date],DOUBLE)

 whatever you prefer

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

@sdhn did you try the above?

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

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.