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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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