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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
_JohnDee_
Regular Visitor

Employee Schedule

Hi everyone,

 

I need to schedule employee start and end by half-hour, depending on an expected and needed number

 

Here are my data :

_JohnDee__0-1721632999614.png

I need to calculate three more columns :

 

"Start" : number of employees that need to start at each half hour to reach the expected number

"End" : number of employees that need to start at each half hour. A work day last 8:30 hour for each employee, so this is start + 8:30

"PresentEmployee" : number of employees present at each half-hour (depending on start and end)

 

here is the results that i expected :

 

_JohnDee__2-1721632412663.png

 

Hre is the results that i have with the following calculated columns, and i d'ont understand why...

 

_JohnDee__1-1721633025990.png

 

START

 

Start = 
VAR CurrentNum = 'EmployeeSchedule'[Numéro de la demi-heure]
VAR ExpectedEmployees = 'EmployeeSchedule'[ExpectedEmployees]
VAR EmployeesPresent = 
    CALCULATE(
        SUM('EmployeeSchedule'[ExpectedEmployees]),
        FILTER(
            'EmployeeSchedule',
            'EmployeeSchedule'[Numéro de la demi-heure] < CurrentNum
        )
    )
RETURN
MAX(0, ExpectedEmployees - EmployeesPresent)

 

 

END

 

End = 
VAR CurrentNum = 'EmployeeSchedule'[Numéro de la demi-heure]
VAR EndNum = CurrentNum - 17
RETURN
IF(
    EndNum > 0,
    CALCULATE(
        SUM('EmployeeSchedule'[Start]),
        FILTER(
            'EmployeeSchedule',
            'EmployeeSchedule'[Numéro de la demi-heure] = EndNum
        )
    ),
    0
)

 

 

PresentEmployees

 

PresentEmployees = 
VAR CurrentNum = 'EmployeeSchedule'[Numéro de la demi-heure]
RETURN
CALCULATE(
    SUM('EmployeeSchedule'[Start]) - SUM('EmployeeSchedule'[End]),
    FILTER(
        'EmployeeSchedule',
        'EmployeeSchedule'[Numéro de la demi-heure] <= CurrentNum
    )
)

 

 

 Thank you very much

1 ACCEPTED SOLUTION
Rakesh1705
Super User
Super User

Source Data. Here expected employees figures are randomly taken.

Rakesh1705_0-1721641006727.png

Rakesh1705_1-1721641066183.png

To calculate the desired result I have added three additional columns named Duration,End Time and Max Employee

Rakesh1705_2-1721641189353.pngRakesh1705_3-1721641203738.png

Rakesh1705_4-1721641271977.png

Start

Rakesh1705_5-1721641320685.png

End

Rakesh1705_6-1721641343695.png

Present Employees

Rakesh1705_8-1721641498898.png

 

If the same way out solves your problem then please accept this as your solution. Happy to help.

View solution in original post

3 REPLIES 3
Rakesh1705
Super User
Super User

Rakesh1705_0-1721641936191.png

Please check present employee formula. I have considered your formula only for the Present employee. If the overall solution is ok with you then please accept the same as the solution.

Rakesh1705
Super User
Super User

Source Data. Here expected employees figures are randomly taken.

Rakesh1705_0-1721641006727.png

Rakesh1705_1-1721641066183.png

To calculate the desired result I have added three additional columns named Duration,End Time and Max Employee

Rakesh1705_2-1721641189353.pngRakesh1705_3-1721641203738.png

Rakesh1705_4-1721641271977.png

Start

Rakesh1705_5-1721641320685.png

End

Rakesh1705_6-1721641343695.png

Present Employees

Rakesh1705_8-1721641498898.png

 

If the same way out solves your problem then please accept this as your solution. Happy to help.

[update] it's ok, my actual formula for Present employees work perfectly [/update]

 

So great ! I think it's perfect !

 

But i can't the see Present employees colum formula. The last screenshot seems not to be the good one.

 

Thank you so much 🙂

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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