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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

Reply
spandy34
Responsive Resident
Responsive Resident

DAX for Financial Year Running Report Employee

I have a Main Employee table that consists Personid, EmpStartDate and EmpEndDate.  I need to create a graph that counts the distinct personid for employees in that financial year that were employeed - I wasnt sure whether to post in Deskop or Dax commands so I have posted in both - hope that is okay.

 

 

 

@danextian@ v-karpurapud  @Ashish_Mathur @cengizhanarslan 

 

 

 

spandy34_1-1778226052002.png

 

 

PersonIdEmpStartDateEmpEndDate
0113519011/03/1986 00:00 
0113519111/04/1988 00:0030/09/2018 00:00
0113519210/09/1979 00:0031/10/2018 00:00
0113519315/02/1988 00:0030/09/2018 00:00
0113519401/04/2023 00:0001/04/2023 00:00
0113519521/09/1987 00:00 
0113519619/09/1988 00:00 
0113519726/03/1977 00:0031/05/2023 00:00
0113519829/04/1986 00:00 
0113519928/09/1987 00:0030/06/2020 00:00
0113520005/12/1988 00:00 
0113520124/04/1989 00:00 
0113520218/01/1988 00:00 
0113520301/02/1988 00:0001/02/2024 00:00
0113520401/02/1988 00:0023/10/2023 00:00
0113520505/02/1988 00:0030/06/2020 00:00
0113520601/08/1989 00:0031/08/2019 00:00
0113520701/02/1990 00:0030/04/2019 00:00
0113520812/02/1990 00:0030/09/2020 00:00
0113520928/10/1986 00:00 
0113521029/02/1988 00:00 
0113521127/09/1982 00:0031/03/2021 00:00
0113521202/01/1990 00:0031/10/2022 00:00
0113521304/12/1989 00:00 
0113521415/01/1990 00:0031/01/2021 00:00
0113521519/04/1990 00:0026/04/2020 00:00
0113521615/10/1990 00:00 
0113521702/07/1990 00:00 
0113521801/02/1989 00:0001/02/2024 00:00
0113521912/04/1989 00:0001/02/2024 00:00
0113522001/01/2018 00:0001/02/2024 00:00
0113522113/06/1988 00:0030/06/2023 00:00
0113522217/04/1990 00:0015/10/2019 00:00
1 ACCEPTED SOLUTION
danextian
Super User
Super User

Hi @spandy34 

Assuming that in your employee table each employee only has one record and making sure that the date table is disconnected from the employee table, try this:

Count by Time Period =
VAR StartDate =
    MIN ( Dates[Date] )
VAR EndDate =
    MAX ( Dates[Date] )
RETURN
    COUNTROWS (
        FILTER (
            EmpData,
            EmpData[EmpStartDate] <= EndDate
                && (
                    ISBLANK ( EmpData[EmpEndDate] ) || EmpData[EmpEndDate] >= StartDate
                )
        )
    )

danextian_0-1778242262052.png

Please see the attached pbix.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

I have solved a similar question in the attached files.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
pcoley
Impactful Individual
Impactful Individual

@spandy34 
Another option:

Create a Calendar / FY table so you can easily slice by Financial Year if you don´t have one yet.

FY Calendar = 
VAR StartYear = 2020
VAR EndYear   = 2027
RETURN
    ADDCOLUMNS(
        GENERATESERIES(
            DATE(StartYear, 4, 1), 
            DATE(EndYear,   3, 31), 
            1
        ),
        "FY", 
        "FY " & FORMAT([Date], "YYYY") & "/" & FORMAT([Date]+365, "YY")
    )

Then mark this table as a Date table and create a relationship to your Employee table on a date (you can use EmpStartDate or create a duplicate inactive relationship if needed).


And the measure:

Active Headcount FY = 
VAR CurrentFYStart = MIN('FY Calendar'[Date])
VAR CurrentFYEnd   = MAX('FY Calendar'[Date])

RETURN
    CALCULATE(
        DISTINCTCOUNT(Employee[PersonId]),
        Employee[EmpStartDate] <= CurrentFYEnd,
        OR(
            ISBLANK(Employee[EmpEndDate]),
            Employee[EmpEndDate] >= CurrentFYStart
        )
    )
If I helped solve your problem, mark this post as a solution.
Kudos are Welcome! | AI assisted for clarity of wording. |
pcoley
Impactful Individual
Impactful Individual

@spandy34 
Please try:

Headcount EOY = 
VAR FYEndDate = MAX('FY Calendar'[Date])
RETURN
    CALCULATE(
        DISTINCTCOUNT(Employee[PersonId]),
        Employee[EmpStartDate] <= FYEndDate,
        OR(ISBLANK(Employee[EmpEndDate]), Employee[EmpEndDate] >= FYEndDate)
    )
If I helped solve your problem, mark this post as a solution.
Kudos are Welcome! | AI assisted for clarity of wording. |
danextian
Super User
Super User

Hi @spandy34 

Assuming that in your employee table each employee only has one record and making sure that the date table is disconnected from the employee table, try this:

Count by Time Period =
VAR StartDate =
    MIN ( Dates[Date] )
VAR EndDate =
    MAX ( Dates[Date] )
RETURN
    COUNTROWS (
        FILTER (
            EmpData,
            EmpData[EmpStartDate] <= EndDate
                && (
                    ISBLANK ( EmpData[EmpEndDate] ) || EmpData[EmpEndDate] >= StartDate
                )
        )
    )

danextian_0-1778242262052.png

Please see the attached pbix.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Thank you very much for your response - it has worked and I amended it as the following to refect table name - thanks again

 

zCount by Time Period =
VAR StartDate =
    MIN ( Dates_Main[Date] )
VAR EndDate =
    MAX ( Dates_Main[Date] )
RETURN
    COUNTROWS (
        FILTER (
            Combined_Person_Post,
            Combined_Person_Post[EmpStartDate] <= EndDate
                && (
                    ISBLANK ( Combined_Person_Post[EmpEndDate] ) || Combined_Person_Post[EmpEndDate] >= StartDate
                )
        )
    )

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors