Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hi,
Can't get what I'm looking for exactly from other posts.
Need to calculate the time difference in hours between the 'Time of Last Call' & the 'Time of First Call' for each 'carer_id'
Solved! Go to Solution.
Here is a measure expression (not a column) that gives your expected results.
TimeDiff =
VAR thisdate =
MIN ( data[Date] )
VAR thisfirst =
MIN ( data[Time of First Call] )
VAR prevdate =
CALCULATE (
MAX ( data[Date] ),
ALL ( data ),
VALUES ( data[carer_id] ),
data[Date] < thisdate
)
VAR prevlast =
CALCULATE (
MAX ( data[Time of Last Call] ),
ALL ( data ),
VALUES ( data[carer_id] ),
data[Date] = prevdate
)
RETURN
IF (
NOT ( ISBLANK ( prevdate ) ),
24
* FIXED ( ( thisdate + thisfirst ) - ( prevdate + prevlast ), 3 )
)
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Here is a measure expression (not a column) that gives your expected results.
TimeDiff =
VAR thisdate =
MIN ( data[Date] )
VAR thisfirst =
MIN ( data[Time of First Call] )
VAR prevdate =
CALCULATE (
MAX ( data[Date] ),
ALL ( data ),
VALUES ( data[carer_id] ),
data[Date] < thisdate
)
VAR prevlast =
CALCULATE (
MAX ( data[Time of Last Call] ),
ALL ( data ),
VALUES ( data[carer_id] ),
data[Date] = prevdate
)
RETURN
IF (
NOT ( ISBLANK ( prevdate ) ),
24
* FIXED ( ( thisdate + thisfirst ) - ( prevdate + prevlast ), 3 )
)
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Still not giving desired result.
Here is my file: https://www.dropbox.com/s/b0uhe3z8ne4unit/sample%20time%20diff.pbix?dl=0
Use datediff function
Column = DATEDIFF('Table'[First],'Table'[Last],HOUR)
don't summurize your time difference column
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!