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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
Fabcon_Europe_Social_Bogo

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.