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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Spencer
Helper II
Helper II

Sum - Headcount

Hi

 

I'm trying to create a calculated column which gives a current headcount at the end of each month.

I've managed to create a table which has the amount of starters and leavers for each month. A result of this is that those without a leave date (i.e. still an active employee) have been lumped into one number totalling 313.  And I think this is why I can't simply sum the Net column to get the current headcount at the end of each month.

 

Thanks and any help greatly appreciated!MonthlyStartersAndLeavers TableMonthlyStartersAndLeavers Table

 

1 ACCEPTED SOLUTION

@Spencer

 

I assume you use "merge queries" with full join to create this table so that those "not match" rows will aggregate together. 

 

In this scenario, I suggest you filter those "not match" rows in your table. You can filter empty rows in Query Editor.

 

Capture66.PNG 

 

If you don't want to modify the table, you can add filter expression in your calculation.

 

 

Headcount = 
CALCULATE(
SUM(MonthlyStartersAndLeavers[Net]),
FILTER (
        ALL ( 'MonthlyStartersAndLeavers'[Months] ),
        'MonthlyStartersAndLeavers'[Months]<>BLANK()
    ),
FILTER(ALL(DateTable[DateKey]),DateTable[DateKey]<=MAX(DateTable[DateKey]))
)

View solution in original post

7 REPLIES 7
Spencer
Helper II
Helper II

Alternatively I've calculated the headcount as a measure, using the below formula, but the -313 is still taken into account.

 

Headcount = CALCULATE(SUM(MonthlyStartersAndLeavers[Net]),FILTER(ALL(DateTable[DateKey]),DateTable[DateKey]<=MAX(DateTable[DateKey])))

 

@Spencer

 

I assume you use "merge queries" with full join to create this table so that those "not match" rows will aggregate together. 

 

In this scenario, I suggest you filter those "not match" rows in your table. You can filter empty rows in Query Editor.

 

Capture66.PNG 

 

If you don't want to modify the table, you can add filter expression in your calculation.

 

 

Headcount = 
CALCULATE(
SUM(MonthlyStartersAndLeavers[Net]),
FILTER (
        ALL ( 'MonthlyStartersAndLeavers'[Months] ),
        'MonthlyStartersAndLeavers'[Months]<>BLANK()
    ),
FILTER(ALL(DateTable[DateKey]),DateTable[DateKey]<=MAX(DateTable[DateKey]))
)

That'll be ideal, huge thanks @v-sihou-msft

CahabaData
Memorable Member
Memorable Member

or, off the cuff, how about at the Visual level doing a running total of the Net column?

www.CahabaData.com

Thanks for the suggestion @CahabaData, but I'm going to need to be using the headcount to create other measures in the future.

Greg_Deckler
Community Champion
Community Champion

I would create a Month column, something like MONTH([MonthS]) and then edit your column so that [Net] is per row. Then, you could just create a table, place [Month] and [Net] in the table and you should get your answer.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Thanks for the response @Greg_Deckler.

Your solution should work out but is there anyway to keep this within my current table?

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

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