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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
EaglesTony
Post Prodigy
Post Prodigy

How can I get a datediff based off the next logical row ?

I have the following table:

 

IssueKey      Status                        FirstTransitionTo

ABC             Backlog                     1/1/2024

ABC             In Progress                1/15/2024

ABC             Review                       1/16/2024

ABC             Done                          2/1/2024

DEF             Backlog                      10/20/2024

DEF             In Progress                 11/1/2024 

 

What I need is a calculated column next to each to check how long it has been in that status for example "ABC has been in Backlog from 1/1/2024-1/15/2024", so 14 days total. using 11/14/2024 as the current date

 

IssueKey      Status                        FirstTransitionTo        DaysInStatus

ABC             Backlog                     1/1/2024                    14                       

ABC             In Progress                1/15/2024                    1

ABC             Review                       1/16/2024                  37

ABC             Done                          2/1/2024                  288

DEF             Backlog                      10/20/2024                 13

DEF             In Progress                 11/1/2024                   14         ----> This is the last status, so use current date in calc

1 ACCEPTED SOLUTION
EaglesTony
Post Prodigy
Post Prodigy

I could try this.

 

What I ended up doing was replicating the original table to other tables based off  Status and then did a group by the IssueKey and seems to work.

View solution in original post

3 REPLIES 3
Kedar_Pande
Super User
Super User

@EaglesTony 

DaysInStatus =
VAR CurrentTransitionDate = 'Table'[FirstTransitionTo]
VAR NextTransitionDate =
CALCULATE(
MIN('Table'[FirstTransitionTo]),
FILTER(
'Table',
'Table'[IssueKey] = EARLIER('Table'[IssueKey]) &&
'Table'[FirstTransitionTo] > CurrentTransitionDate
)
)
VAR EndDate =
IF(ISBLANK(NextTransitionDate), DATE(2024, 11, 14), NextTransitionDate)
RETURN
DATEDIFF(CurrentTransitionDate, EndDate, DAY)

💌 If this helped, a Kudos 👍 or Solution mark would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn

EaglesTony
Post Prodigy
Post Prodigy

I could try this.

 

What I ended up doing was replicating the original table to other tables based off  Status and then did a group by the IssueKey and seems to work.

Gabry
Super User
Super User

Check this out

 

DaysInStatus = 
VAR CurrentDate = 'Tabella'[        FirstTransitionTo]
VAR NextDate = 
    CALCULATE(
        MIN('Tabella'[        FirstTransitionTo]),
        FILTER(
            'Tabella',
            'Tabella'[IssueKey   ] = EARLIER('Tabella'[IssueKey   ]) &&
            'Tabella'[        FirstTransitionTo] > CurrentDate
        )
    )
RETURN 
    IF(
        ISBLANK(NextDate),
        DATEDIFF(CurrentDate, TODAY(), DAY), 
        DATEDIFF(CurrentDate, NextDate, DAY)
    )

 

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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