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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
lheilig
New Member

Calculating Time to Return Across Multiple Rows

Hi All! I've been using Power BI for a little while now, but my Google Fu is failing me on this one. 

I have a list of customers with Unique Ids and their Dates of Arrive and Departure. I can easily capture my frequent flyers and how often they use our services but what I'm really looking for is time between visits. Here's an example of my data table:

IDLastFirstArriveDepart
548RossBetsy5/17/225/20/22
548RossBetsy5/30/226/3/22
233LipaDua5/17/225/19/22
233LipaDua6/1/226/5/22
233LipaDua6/20/226/23/22
667LopezJennifer5/20/225/25/22
999WayneBruce5/19/225/30/22
999WayneBruce6/15/226/17/22
999WayneBruce6/30/227/4/22

 

So what I'm trying to find is: for each person that visits multiple times, what was the interval between the departure and the next arrival.  I cannot seem to find the solution for this one. 

Any help is greatly appreciated!!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @lheilig ,

 

Please check the formula.

Column = 
var next_arrive = CALCULATE(MIN('Table'[Arrive]),FILTER(ALLEXCEPT('Table','Table'[ID]),'Table'[Depart]>EARLIER('Table'[Depart])))
return
IF(ISBLANK(next_arrive),0,DATEDIFF('Table'[Depart],next_arrive,DAY))

vjaywmsft_0-1658906095136.png

 

Best Regards,

Jay

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @lheilig ,

 

Please check the formula.

Column = 
var next_arrive = CALCULATE(MIN('Table'[Arrive]),FILTER(ALLEXCEPT('Table','Table'[ID]),'Table'[Depart]>EARLIER('Table'[Depart])))
return
IF(ISBLANK(next_arrive),0,DATEDIFF('Table'[Depart],next_arrive,DAY))

vjaywmsft_0-1658906095136.png

 

Best Regards,

Jay

Jos_Woolley
Solution Sage
Solution Sage

Hi,

Perhaps add your manually calculated expected results for that dataset. Thay way potential solutions can be tested.

Regards

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors