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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Employee Count - Returns strange numbers

Hello all,

 

I have an emloyee table and created a measure called employee count.

 

Employee Count =
VAR selectedDate = MAX('Date'[Date])

RETURN

CALCULATE(COUNTROWS('All Employees'), FILTER('All Employees', 'All Employees'[DTHired]<= selectedDate && OR('All Employees'[DTTerminated] >= selectedDate, ISBLANK('All Employees'[DTTerminated]))))
 
However, the results it returns are incorrect. I did some research and found out that it is counting theincorrect number of terminstions. Also, if I change the function to say all employees who where terminated before they hire it finds employees.... this is impossible. Here is the impossible function that still seems to find people.
 
Employee Count =
VAR selectedDate = MAX('Date'[Date])

RETURN

CALCULATE(COUNTROWS('All Employees'), FILTER('All Employees', 'All Employees'[DTHired]>= selectedDate && 'All Employees'[DTTerminated] <= selectedDate))
 
and here is the graph it returns:
This should be zero every month.This should be zero every month.
 
This should be zero every month as employees are not terminated before hire.
 
Any help or ideas for a measure that would actually count my emplyees would be lovely.
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Thank you for the idea! It gives diferent numbers but they stil lare not correct and it finds employees who were terminated before they were hired. Using a different measure I can calculate it properly: 

Current Employees = CALCULATE(COUNTx(FILTER('All Employees','All Employees'[DTHired]<=max('Date'[Date]) && (ISBLANK('All Employees'[DTTerminated]) || 'All Employees'[DTTerminated]>max('Date'[Date]))),('All Employees'[Employee Id])),CROSSFILTER('All Employees'[DTHired],'Date'[Date],None))

View solution in original post

2 REPLIES 2
Greg_Deckler
Community Champion
Community Champion

@Anonymous Maybe try this:

Employee Count =
  VAR __selectedDate = MAX('Date'[Date])
  VAR __Table = 
    FILTER(
      ALL('All Employees'),
      [DTHired] <= __selectedDate && ( [DTTerminated] = BLANK() || [DTTerminated] >= __selectedDate )
    )
  VAR __Result = COUNTROWS(DISTINCT(__Table))
RETURN
  __Result


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...
Anonymous
Not applicable

Thank you for the idea! It gives diferent numbers but they stil lare not correct and it finds employees who were terminated before they were hired. Using a different measure I can calculate it properly: 

Current Employees = CALCULATE(COUNTx(FILTER('All Employees','All Employees'[DTHired]<=max('Date'[Date]) && (ISBLANK('All Employees'[DTTerminated]) || 'All Employees'[DTTerminated]>max('Date'[Date]))),('All Employees'[Employee Id])),CROSSFILTER('All Employees'[DTHired],'Date'[Date],None))

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.

Top Solution Authors