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

View all the Fabric Data Days sessions on demand. View schedule

Reply
boa
Helper I
Helper I

Timedifference between diffrent records (taking in account the day and location)

Hello,

I wonder if this is possible.  I'd like to calculate the duration between 2 records based on the date and the location.

This is how the database looks like: 

boa_1-1662411668900.png

 

So I like to know how much time there is between the appointments. The result should be something like this:

boa_0-1662411607626.png

Sometimes people don't show up for their appointment. It would be awesome if it is also possible to calculate also the time between appointments not taking the status 'not showing up' in account. 

 

boa_2-1662412580038.png

 

Thank you in advance!

1 ACCEPTED SOLUTION

@boa 

updated the DAX

pls see the attachment below





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

5 REPLIES 5
boa
Helper I
Helper I

@ryan_mayu Thank you very much for your help. The syntax in DAX works 🙂

you are welcome





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




ryan_mayu
Super User
Super User

@boa 

pls try this

Column = 
VAR _last=maxx(FILTER('Table',year('Table'[Start])=year(EARLIER('Table'[Start]))&&'Table'[Start]<EARLIER('Table'[Start])&&'Table'[Location]=EARLIER('Table'[Location])),'Table'[End])
return if(ISBLANK(_last),_last,('Table'[Start]-_last)*24*60)

Column 2 = 
VAR _last=maxx(FILTER('Table',year('Table'[Start])=year(EARLIER('Table'[Start]))&&'Table'[Start]<EARLIER('Table'[Start])&&'Table'[Location]=EARLIER('Table'[Location])&&'Table'[Status]<>"not showing up"),'Table'[End])
return if(ISBLANK(_last)||'Table'[Status]="not showing up",blank(),('Table'[Start]-_last)*24*60)

1.PNG

 

pls see the attachment below





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi Ryan

Thanks for your suggestion. Most of the calculation are correct, but your expression don't take a new day in account. If I try your suggestion, I get this:

 

boa_0-1662501147475.png

The results in green are correct. The results in red should be 0 because it is the first appointment of that day (on that location) but I have no idea how to fix that...

 

 

@boa 

updated the DAX

pls see the attachment below





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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
Top Kudoed Authors