Forum

Determine Duration ...
 
Notifications
Clear all

Determine Duration for Consecutive and Non-Consecutive Dates

2 Posts
1 Users
0 Reactions
242 Views
(@pseudomvp)
Posts: 6
Active Member
Topic starter
 

Hi Everyone,

I'm working with a column called "DateCol Transposed," which contains transposed date values of the "Date" column for unique IDs (see attached). 

2.PNG

As you can see, each table value is a nested record for an ID, and the dates are in ascending order. I need to determine the duration it took to fix a process based on these failure dates. A non-consecutive/single date (has no succeeding date) is considered one instance of failure.  A consecutive date range (has subsequent succeeding dates excluding weekends) is considered just one instance of failure also.

For example, a given ID has the dates 6/17/2024, 6/19/2024, 6/20/2024, 6/21/2024, and 6/26/2024, the process failed in three instances:

  1. 6/17/2024 (non-consecutive), corrected by 6/18/2024.
  2. 6/19/2024 to 6/24/2024 (consecutive), corrected on 6/24/2024.
  3. 6/26/2024 (non-consecutive), corrected by 6/27/2024.

I want to add a column that captures each failure instance, correction date, and duration (excluding weekends). The result should look like this:

Failed Date Correction Date Duration (Excludes weekends)
6/17/2024 6/18/2024 1
6/19/2024 6/24/2024 3
6/26/2024 6/27/2024 1

For consecutive dates, only the first and last dates should be picked. For non-consecutive dates, the correction date is the day after the failed date.

I've written a formula to extract the first and last dates, but it doesn't handle mixed consecutive and non-consecutive dates correctly (see attached screenshot which follows the prior screenshot example and the formula below):

1.PNG

Table.RenameColumns(Table.SelectColumns([DateCol Transposed],
if Table.ColumnCount([DateCol Transposed]) = 1 then {Table.ColumnNames([DateCol Transposed]){0}} else {Table.ColumnNames([DateCol Transposed]){0}, Table.ColumnNames([DateCol Transposed]){Table.ColumnCount([DateCol Transposed])-1}}),

if Table.ColumnCount(Table.SelectColumns([DateCol Transposed], if Table.ColumnCount([DateCol Transposed]) = 1 then {Table.ColumnNames([DateCol Transposed]){0}} else {Table.ColumnNames([DateCol Transposed]){0}, Table.ColumnNames([DateCol Transposed]){Table.ColumnCount([DateCol Transposed])-1}})) = 1 then {} else {{Table.ColumnNames(Table.SelectColumns( [DateCol Transposed],

if Table.ColumnCount([DateCol Transposed]) = 1 then {Table.ColumnNames([DateCol Transposed]){0}} else {Table.ColumnNames([DateCol Transposed]){0}, Table.ColumnNames([DateCol Transposed]){Table.ColumnCount([DateCol Transposed])-1}})){1}, "Column2"}})

Any help would be greatly appreciated.

Thanks!

 
Posted : 09/07/2024 5:32 pm
(@pseudomvp)
Posts: 6
Active Member
Topic starter
 

I noticed in my example above I accidentally left out 6/24/2024, but the result in the table is correct.

So to clarify here is a better example.  If I expand the table values for the ID's (as shown in the attachment) the table will look like this:

ID Column1 Column2 Column3 Column4 Column5 Column6
123 6/17/2024 6/19/2024 6/20/2024 6/21/2024 6/24/2024 6/26/2024
999 6/17/2024          
888 6/18/2024 6/19/2024        
777 6/10/2024 6/12/2024 6/13/2024      

I need to transform the data to look like this using the rules I mentioned above:

ID Failed Date Correction Date Duration (Excluding weekends)
123 6/17/2024 6/18/2024 1
123 6/19/2024 6/24/2024 3
123 6/26/2024 6/27/2024 1
999 6/17/2024 6/18/2024 1
888 6/18/2024 6/19/2024 1
777 6/10/2024 6/11/2024 1
777 6/12/2024 6/13/2024 2

Note: the second row is consecutive dates but excludes weekends thus the duration is 3 days

Anyone?

 
Posted : 11/07/2024 2:08 pm
Share: