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! Request now

Reply
mcflurry
Helper I
Helper I

Calculate duration with start and end date in two tables

I'm trying to calculate duration with two columns from two tables.

 

mcflurry_0-1646749756802.png

I've tried adding a column in one of the tables with this code:

Duration = ('Started'[Start Time] - RELATED(Completed[End Time]))
But it gives an error:
"A single value for column 'Start Time' in table 'Started' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result."
 
I've tried DATEDIFF too, but i can only pick columns from one of the tables, can't use two tables.
 
Any suggestion?
1 ACCEPTED SOLUTION

A column called "ID".

 

OK

 

Finally got it with this:

 

Duration = DATEDIFF(MAXX(RELATEDTABLE(Started),'Started'[Start Time]),Completed[End Time],MINUTE)

View solution in original post

5 REPLIES 5
johnt75
Super User
Super User

Try SELECTEDVALUE()

Duration = DATEDIFF( SELECTEDVALUE('Started'[Start Time]), SELECTEDVALUE( 'Completed'[End Time]), MINUTE )
Syk
Super User
Super User

Try something like this...

Duration = DATEDIFF(MAX('Started'[Start Time]),MAX(Completed[End Time]),MINUTE)

It "works", it justs displays the same result for every row.

What's the relationship between the two tables?

A column called "ID".

 

OK

 

Finally got it with this:

 

Duration = DATEDIFF(MAXX(RELATEDTABLE(Started),'Started'[Start Time]),Completed[End Time],MINUTE)

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