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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
StacyL
New Member

Finding the DateDiff between to different columns in two different rows AFTER filtering data.

I have a large amount of data (8900 rows of data) that is categorized at 3 different levels (company, department, team). I have created an index for all items as well as an index for the items that are within the same team. I have a start date and end date for each item in the data. I need to know what the downtime is between each record within each specific team. For example, for Team A their first record ended on 01/01/2019 and their second record started on 02/15/2019, what is the downtime gab between when #1 ended and #2 started, etc. 

 

I have also tried to just simply return the previous record's end date from #1 into a new column of #2 without success.  Again the filtering has me baffled.

 

While both formulas I am using ARE returning data it is not "filtered/grouped" data so it is not accurately reflecting what I am looking for.

 

I can not for the life of me figure out how to get it to filter the data first then run the datediff... etc.

 

Here is my datediff formula for the downtime...

 

Downtime = DATEDIFF(MAXX(FILTER(ALL('Department Change Data'),'Department Change Data'[TeamLevelIndex]=EARLIER('Department Change Data'[TeamLevelIndex])&&[Actual End date]<EARLIER('Department change Data'[Created Date Time])),[Actual End Date]),[Created Date Time],DAY)

 

Here is my formula trying to return the previous record's end date:

Date_Ended_prev = var currentteamindex = 'Department Change Data'[TeamLevelIndex]
var currentTeam = 'Department Change Data'[Team]
return CALCULATE( MAX('Department Change Data'[Actual End Date])
,FILTER('Department Change Data', 'Department Change Data'[Team]=currentTeam) ,'Department Change Data'[Index] = currentTeamIndex - 1)

 

My ultimate end goal is to determine what the average number of days are between Changes for each team within a department and company. 

 

If I can get one or the other to work I would be golden! Thanks in advance for any help!

0 REPLIES 0

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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

Top Solution Authors