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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
ABR002
Helper I
Helper I

Number of Days from earliest date to latest date based on changes in 2 columns

I am running into another issue with this project, I need to calculate the number of days an employee spends in a status before changing statuses:

NameStatusPeriod End Date
DaveActive6/30/2022
ShellyInactive6/30/2022
RoyInactive6/30/2022
TomActive6/30/2022
MonicaActive6/30/2022
DaveInactive6/23/2022
ShellyInactive6/23/2022
RoyInactive6/23/2022
TomInactive6/23/2022
MonicaActive6/23/2022
DaveInactive6/16/2022
ShellyInactive6/16/2022
RoyInactive6/16/2022
TomActive6/16/2022
MonicaActive6/16/2022


I would just be going of the number of days from period end date to period end data. I'd need to basically say that from Above, Dave was in Inactive Status for 14 Days, as he first had an inactive status on 6/16 and that changed 14 days later on 6/30. Thanks as always

    



1 ACCEPTED SOLUTION
SQL_SousChef
Frequent Visitor

Maybe try this?

DaysUntilNextDate =
VAR CurrentRowDate = [Period End Date]
VAR CurrentName = [Name]
VAR NextDateIndex =
    CALCULATE(
        MAX('TeamData'[Period End Date]),
        FILTER(
            'TeamData',
            'TeamData'[Name] = CurrentName && 'TeamData'[Period End Date] > CurrentRowDate
        )
    )
RETURN
    IF(
        ISBLANK(NextDateIndex),
        BLANK(),
        NextDateIndex - CurrentRowDate
    )
 
SQL_SousChef_0-1695954294487.png

 

View solution in original post

1 REPLY 1
SQL_SousChef
Frequent Visitor

Maybe try this?

DaysUntilNextDate =
VAR CurrentRowDate = [Period End Date]
VAR CurrentName = [Name]
VAR NextDateIndex =
    CALCULATE(
        MAX('TeamData'[Period End Date]),
        FILTER(
            'TeamData',
            'TeamData'[Name] = CurrentName && 'TeamData'[Period End Date] > CurrentRowDate
        )
    )
RETURN
    IF(
        ISBLANK(NextDateIndex),
        BLANK(),
        NextDateIndex - CurrentRowDate
    )
 
SQL_SousChef_0-1695954294487.png

 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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