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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
HappyBeckmann
Regular Visitor

Calculate new employees per month

Hey there,

I am trying to create a visual with the new employees for each month. Positions can occur several times but not at the same time. For example Position P-10057.

ValidFromValidToFullTimeEquivalentPositionId
31.12.202331.12.2154  0.2P-10016
01.12.201231.12.2154  1P-10017
18.01.201631.12.2154  1P-10055
01.09.201731.12.2154  1P-10056
01.02.202331.12.2023  1P-10057
30.06.202414.10.2024  1P-10057
14.11.202329.02.2024  1P-10058
31.07.202431.12.2154  1P-10058
01.08.202104.06.2024  1P-10059
01.08.202230.07.2025  1P-10060
01.08.202231.07.2025  1P-10061
15.08.202213.08.2025  1P-10062
01.08.202330.07.2026  1P-10063
01.08.202308.05.2024  1P-10064
01.08.202104.06.2024  1P-10065


I use the following Dax:

FTE_Onboarding =
CALCULATE(
    SUM(PositionWorkerAssignmentsV2[FullTimeEquivalent]),
    FILTER(
        PositionWorkerAssignmentsV2,
        PositionWorkerAssignmentsV2[ValidFrom] >= MIN(DateTable[Date]) &&
        PositionWorkerAssignmentsV2[ValidFrom] <= MAX(DateTable[Date])
    )
)


The datetable goes from 2022 to 2026. So the missing FTE before 2022 are correct.
However I am get the following result:

FTE_OnboardingYearMonth
32022August
12023Februar
22023August
12023November


So the FTE from Dec 23 and the two FTE from 24 are missing.


Looking forward to your answers 🙂
9 REPLIES 9
DataNinja777
Super User
Super User

Hi @HappyBeckmann ,

 

You can produce your required output by writing the following dax measure.

FTE_Onboarding = 
CALCULATE(
    SUM(PositionWorkerAssignmentsV2[FullTimeEquivalent]),
    FILTER(
        ALL(PositionWorkerAssignmentsV2),  // Removes any existing filters on PositionWorkerAssignmentsV2
        PositionWorkerAssignmentsV2[ValidFrom] >= MIN(DateTable[Date]) &&
        PositionWorkerAssignmentsV2[ValidFrom] <= MAX(DateTable[Date])
    )
)

The resulting output is as shown below:

DataNinja777_0-1731506768370.png

I have attached an example pbix file for your reference.

 

Best regards,

 

 

Thank you for your reply 🙂

The problem seems to be my date table.
I am still trying to figure out why, because it seems to work till Dec 2023

Hi @HappyBeckmann ,

 

I didn’t mention this earlier, but I found it a bit unusual that your employees have durations exceeding 100 years, as shown below. They certainly have remarkable longevity and tenure!

DataNinja777_1-1731508713923.png

Best regards,

 

Haha maybe we have found the fountain of youth 😉
Na actually we use F&O and employees with a permanent contract with no end date seem to get the max date of F&O

AntrikshSharma
Super User
Super User

@HappyBeckmann I think there is an issue with your dates table, I haven't even started yet I can see the FTEs for the missing months you have mentioned.

 

AntrikshSharma_0-1731505864788.png

 

Refer to the file attached below.

Thank you for your reply 🙂
I managed to make it work by instead of using the datetable in the visual I am using the ValidFrom.
So you are correct.

My datetable looks like this:

DateTable =
CALENDAR(
    DATE(2022, 1, 1),
    DATE(YEAR(TODAY()) + 2, 12, 31)
)
Data type is date
Format is short date

Valid From has data type date and time

Maybe that's the issue? But why does it work till end of 2023? 
johnt75
Super User
Super User

Try

FTE Onboarding = 
VAR StartDate = MIN('Date'[Date])
VAR EndDate = MAX('Date'[Date])
VAR Result = CALCULATE(
    SUM('Table'[FullTimeEquivalent]),
    'Table'[ValidFrom] >= StartDate
    && 'Table'[ValidFrom] <= EndDate
)
RETURN
    Result

Thank you for your reply 🙂
However it seems like the dax is not the problem but the date table

There's a few things you could try. Firstly check that Power BI hasn't automatically created any relationships between your date table and the fact table.

For the fact table, change the datetime to date. You'll need to do this both in Power Query and in the modelling view. If you only do it in the modelling view it will silently retain the time part.

Make sure that the date table is marked as a date table.

Finally, have a look at the date table and make sure that it does have all the dates you expect. Its very easy to make a typo and end up with 

YEAR( TODAY() + 2)

rather than

YEAR( TODAY() ) + 2

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors