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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Shrujan1612
Helper I
Helper I

Employee Headcount

Monthshort Fy yearHEADCOUNTCUMULATIVE HEADCOUNT
OCTFY202362696269
NOVFY2023631412583
DECFY2023636918952
JANFY2023645025402
FEBFY2023695932361
MARFY2023699739358
APRFY2023704946407
MAYFY2023710053507
JUNFY2023724060747
JULFY2023746668213
AUGFY2023754475757
SEPFY2023761383370

 

 

my expected result is column cumulative headcount. I have already created measure for Headcount column it is working fine. Can anyone help me how to achieve the cumulative headcount values based on date selection cumulative should start from last 12 months.

Headcount =

VAR seledate = MAX(Employee[EMP_HIRE_DT])

 

RETURN

    CALCULATE(

            DISTINCTCOUNT(Employee[EMPLOYEE_NUM]),

           FILTER(ALL(Employee), seledate >= Employee[EFFECTIVE_FROM_DT] &&

            seledate <= Employee[EFFECTIVE_TO_DT]

    ),

    CROSSFILTER('Time'[CALENDAR_DATE],Employee[EMP_HIRE_DT],None))

2 ACCEPTED SOLUTIONS
bhanu_gautam
Super User
Super User

@Shrujan1612 , Try using below measure

 

CumulativeHeadcount =
VAR MaxDate = MAX('Time'[CALENDAR_DATE])
VAR MinDate = EDATE(MaxDate, -11) -- This will get the date 11 months before the MaxDate
RETURN
CALCULATE(
SUM(Employee[Headcount]),
FILTER(
ALL('Time'),
'Time'[CALENDAR_DATE] >= MinDate && 'Time'[CALENDAR_DATE] <= MaxDate
)
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






View solution in original post

Anonymous
Not applicable

Hi, @Shrujan1612 

Thanks for the reply from bhanu_gautam, please allow me to provide addition:

Based on your information, I create sample tables:

Employee table

vyohuamsft_0-1726712445218.png

Table

vyohuamsft_1-1726712518031.png

 

Since I didn't have accurate information about the people, I just summarized it into how many people there were in each month when I created the sample Employee table.

Then create measures Headcount and cumulative headcount, try the following dax:

HEADCOUNT = SUM('Empolyee'[EMPLOYEE])
CUMULATIVE HEADCOUNT = 
VAR MaxDate = MAX('Time'[CALENDAR_DATE])
VAR MinDate = EDATE(MaxDate, -11) 
RETURN
    CALCULATE(
        [HEADCOUNT],
        FILTER(
            ALL('Time'),
            'Time'[CALENDAR_DATE] >= MinDate &&
            'Time'[CALENDAR_DATE] <= MaxDate
        )
    )

 

Create a table visual and put fields in table view, here is my preview:

vyohuamsft_3-1726712941398.png

 

How to Get Your Question Answered Quickly

Best Regards

Yongkang Hua

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi, @Shrujan1612 

Thanks for the reply from bhanu_gautam, please allow me to provide addition:

Based on your information, I create sample tables:

Employee table

vyohuamsft_0-1726712445218.png

Table

vyohuamsft_1-1726712518031.png

 

Since I didn't have accurate information about the people, I just summarized it into how many people there were in each month when I created the sample Employee table.

Then create measures Headcount and cumulative headcount, try the following dax:

HEADCOUNT = SUM('Empolyee'[EMPLOYEE])
CUMULATIVE HEADCOUNT = 
VAR MaxDate = MAX('Time'[CALENDAR_DATE])
VAR MinDate = EDATE(MaxDate, -11) 
RETURN
    CALCULATE(
        [HEADCOUNT],
        FILTER(
            ALL('Time'),
            'Time'[CALENDAR_DATE] >= MinDate &&
            'Time'[CALENDAR_DATE] <= MaxDate
        )
    )

 

Create a table visual and put fields in table view, here is my preview:

vyohuamsft_3-1726712941398.png

 

How to Get Your Question Answered Quickly

Best Regards

Yongkang Hua

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

bhanu_gautam
Super User
Super User

@Shrujan1612 , Try using below measure

 

CumulativeHeadcount =
VAR MaxDate = MAX('Time'[CALENDAR_DATE])
VAR MinDate = EDATE(MaxDate, -11) -- This will get the date 11 months before the MaxDate
RETURN
CALCULATE(
SUM(Employee[Headcount]),
FILTER(
ALL('Time'),
'Time'[CALENDAR_DATE] >= MinDate && 'Time'[CALENDAR_DATE] <= MaxDate
)
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Headcount is a measure we cant use it in sum.

@Shrujan1612 , try this then

 

CumulativeHeadcount =
VAR MaxDate = MAX('Time'[CALENDAR_DATE])
VAR MinDate = EDATE(MaxDate, -12)
RETURN
CALCULATE(
SUMX(
FILTER(
ALL('Time'),
'Time'[CALENDAR_DATE] >= MinDate &&
'Time'[CALENDAR_DATE] <= MaxDate
),
[Headcount]
)
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.