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
Rohitb
Helper I
Helper I

Extrapolation of Data as per use case

Hello

I have the below dataset at my disposal.

EmloyeeIdDOJDOLIsContinuityNeededContinuedFor
17/28/20229/25/20231 
29/23/202311/30/20231 
310/2/2023   
45/30/20239/15/20231 
52/25/20239/10/2023  
612/15/2023  4
711/5/2023  2
812/6/2023   



I need to extrapolate/populate the data as per below

MonthEmployee ID
23-Sep1
23-Sep2
23-Sep4
23-Sep5
23-Oct1
23-Oct2
23-Oct3
23-Oct4
23-Oct5
23-Nov1
23-Nov2
23-Nov3
23-Nov4
23-Dec1
23-Dec3
23-Dec6
23-Dec7
23-Dec8


Here the requriment is :

Employees with No Departure Date (DOL):
For employees without a departure date (DOL), their records should be populated from the month they joined (DOJ) until the maximum month for which we have data. (Example EmployeeID : 3 & 8 )

Employees with Departure Dates and No Continuity Requirement (IsContinuityNeeded is blank):
For employees with departure dates (DOL) and no continuity requirement (IsContinuityNeeded is blank), their records should span from the month of thier date of joining (DOJ) until their departure month (DOL date month). (Example EmployeeID : 5)

Employees with Departure Dates and Continuity Requirement (IsContinuityNeeded is 1):
a. If there's no replacement employee (ContinuedFor column is blank), the records should cover the period from the employee's month of joining (DOJ) until the maximum month for which we have data. (Example EmployeeID : 1 )
b. If a replacement employee exists, and they joined before the departing employee (DOJ of replacement < DOL of departed), exclude the records of the new employee till the departure month of date of old employee (DOL). (Example EmployeeID : 2/7 )
c. If a replacement employee exists, and they joined after the departing employee left (DOJ of replacement > DOL of departed), include record of the departing employee for the months between their departure date (DOL) and the replacement employee's date of joining (DOJ). (Example EmployeeID : 6/4 )

 

Can someone help me with this ?


1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

MEASURE =
VAR d =
    SELECTEDVALUE ( 'Calendar'[Date] )
VAR e =
    EVALUATEANDLOG (
        ADDCOLUMNS (
            Employees,
            "Replacement Start",
                VAR em = [EmloyeeId]
                RETURN
                    MINX ( FILTER ( ALL ( Employees ), [ContinuedFor] = em ), [DOJ] ) -- start date for replacement employee
                    ,
            "New DOJ",
                IF (
                    ISBLANK ( [ContinuedFor] ),
                    [DOJ],
                    VAR pem = [ContinuedFor]
                    RETURN
                        MAX (
                            [DOJ],
                            MAXX ( FILTER ( ALL ( Employees ), [EmloyeeId] = pem ), [DOL] ) + 1
                        )
                )
        )
    ) -- adjusted start date for replacing employee
VAR a =
    ADDCOLUMNS (
        e,
        "in",
            SWITCH (
                TRUE (),
                d >= [New DOJ]
                    && ISBLANK ( [DOL] ), 1,
                -- no end date
                d >= [New DOJ]
                    && d <= [DOL]
                    && ISBLANK ( [IsContinuityNeeded] ), 1,
                -- end date without continuity
                d >= [New DOJ]
                    && ISBLANK ( [Replacement Start] ), 1,
                -- end date, continuity needed but no replacement
                d >= [New DOJ]
                    && [Replacement Start] < [DOL]
                    && d <= [DOL], 1,
                --replacement starts before DOL - continue until DOL
                d >= [New DOJ]
                    && [Replacement Start] >= [DOL]
                    && d < [Replacement Start], 1 --replacement starts after DOL - continue until Replacement
            )
    )
RETURN
    SUMX ( a, [in] )

This is not something you should do in Power BI. Too complex.

 

See attached.

 

 

View solution in original post

1 REPLY 1
lbendlin
Super User
Super User

MEASURE =
VAR d =
    SELECTEDVALUE ( 'Calendar'[Date] )
VAR e =
    EVALUATEANDLOG (
        ADDCOLUMNS (
            Employees,
            "Replacement Start",
                VAR em = [EmloyeeId]
                RETURN
                    MINX ( FILTER ( ALL ( Employees ), [ContinuedFor] = em ), [DOJ] ) -- start date for replacement employee
                    ,
            "New DOJ",
                IF (
                    ISBLANK ( [ContinuedFor] ),
                    [DOJ],
                    VAR pem = [ContinuedFor]
                    RETURN
                        MAX (
                            [DOJ],
                            MAXX ( FILTER ( ALL ( Employees ), [EmloyeeId] = pem ), [DOL] ) + 1
                        )
                )
        )
    ) -- adjusted start date for replacing employee
VAR a =
    ADDCOLUMNS (
        e,
        "in",
            SWITCH (
                TRUE (),
                d >= [New DOJ]
                    && ISBLANK ( [DOL] ), 1,
                -- no end date
                d >= [New DOJ]
                    && d <= [DOL]
                    && ISBLANK ( [IsContinuityNeeded] ), 1,
                -- end date without continuity
                d >= [New DOJ]
                    && ISBLANK ( [Replacement Start] ), 1,
                -- end date, continuity needed but no replacement
                d >= [New DOJ]
                    && [Replacement Start] < [DOL]
                    && d <= [DOL], 1,
                --replacement starts before DOL - continue until DOL
                d >= [New DOJ]
                    && [Replacement Start] >= [DOL]
                    && d < [Replacement Start], 1 --replacement starts after DOL - continue until Replacement
            )
    )
RETURN
    SUMX ( a, [in] )

This is not something you should do in Power BI. Too complex.

 

See attached.

 

 

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.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.