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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
MauriceMecowe
Resolver II
Resolver II

Subtract two dates from one table

Hi,

 

I have one table with all the activities made on 1 appointment, as depicted on the image below. The activityId shows that the 2 records belong to the same appointment. Now I would like to have a measure or calculated column, which shows the difference in Days between the two records. I tried this in several ways, but couldn't get the desired result.

 

MauriceMecowe_0-1606908134904.png

 

It's always the case that activityStatusValue 935000008 timestamp is subtracted by the timestamp of activityStusValue 935000000 for the same activityId.

 

 

All help is greatly appreciated!

 

Thanks,

Maurice

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@MauriceMecowe , Try a new column like

new column =
var _id =activityId
return
datediff(maxx(filter(Table, [activityId] =_id && [activityStatusValue] = 935000008 ),[timestamp]),maxx(filter(Table, [activityId] =_id && [activityStatusValue] = 935000000 ),[timestamp]), second)

or

new column =
var _id =activityId
return
ifr([activityStatusValue] = 935000000 , datediff(maxx(filter(Table, [activityId] =_id && [activityStatusValue] = 935000008 ),[timestamp]),maxx(filter(Table, [activityId] =_id && [activityStatusValue] = 935000000 ),[timestamp]), second) , blank())

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@MauriceMecowe , Try a new column like

new column =
var _id =activityId
return
datediff(maxx(filter(Table, [activityId] =_id && [activityStatusValue] = 935000008 ),[timestamp]),maxx(filter(Table, [activityId] =_id && [activityStatusValue] = 935000000 ),[timestamp]), second)

or

new column =
var _id =activityId
return
ifr([activityStatusValue] = 935000000 , datediff(maxx(filter(Table, [activityId] =_id && [activityStatusValue] = 935000008 ),[timestamp]),maxx(filter(Table, [activityId] =_id && [activityStatusValue] = 935000000 ),[timestamp]), second) , blank())

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.