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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

How to calculate duration in minutes between two coloms

Hello guys,

 

the next challenge for me is to calculate the DURATION_SOLUTION in minutes(integer).

 

In the current table  i have a formule for DURATION_SOLUTION, which is ENDTIME - STARTTIME. in the following image is an example (see the red markered) that the CI_NAAM Clarity has a negative duration_solution.


This incident is at 02-01-2017 started en ended two days later at 04-01-2017. So basically i expected the total duration_solution in minutes 1476 minutes.

 

How can i fix this ? Thank you all.

 

 

2017-02-02 14_36_46-Orakel_performance_v1 - Power BI Desktop.png

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous,

 

You can try to use below formula to calculate the date diff from date and time.

 

Calculate column:

 

TimeDiff(Minute) = 
var dayDiff = DATEDIFF(DATEVALUE([StartDate]),DATEVALUE([EndDate]),MINUTE)
var hourDiff=LEFT([EndTime],2)- LEFT([StartTime],2)
var minuteDiff= RIGHT([EndTime],2)-RIGHT([StartTime],2)
return
dayDiff + hourdiff *60 + minuteDiff

 

In my sample, startdate and enddate are text format, enddate and startdate are number type.

 

 

Regards,

Xiaoxin Sheng

View solution in original post

4 REPLIES 4
tringuyenminh92
Memorable Member
Memorable Member

Hi @Anonymous,

 

You could use formula:  DURATION_SOLUTION= datediff(STARTDATE,ENDDATE,Minute) + (ENDTIME - STARTTIME)

Anonymous
Not applicable

Hello @tringuyenmingh92,

 

Thanks for your response but unfortunatly this measure doesnt work. Check the underneath result.

 

2017-02-02 15_53_33-Orakel_performance_v1 - Power BI Desktop.png

 

Anonymous
Not applicable

Hi @Anonymous,

 

You can try to use below formula to calculate the date diff from date and time.

 

Calculate column:

 

TimeDiff(Minute) = 
var dayDiff = DATEDIFF(DATEVALUE([StartDate]),DATEVALUE([EndDate]),MINUTE)
var hourDiff=LEFT([EndTime],2)- LEFT([StartTime],2)
var minuteDiff= RIGHT([EndTime],2)-RIGHT([StartTime],2)
return
dayDiff + hourdiff *60 + minuteDiff

 

In my sample, startdate and enddate are text format, enddate and startdate are number type.

 

 

Regards,

Xiaoxin Sheng

Hi @Anonymous

 

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.

Top Solution Authors