Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hello all,
I have a measure that works perfect to calculate my ending head counts for all employees except it doesn't recount an employee once they have been rehired. in my image you see that i am looking to count them for every month they were here once they were terminated i stopped counting them and start counting them again based on their rehired date. i have one table with all this info.
i have a total employees measure that counts each distinct empno. (for this case i filtered my data to one employee that has this scenario so i can figure it out.
My ending head count measure is .
i am lost as to how to enter the rehire variable in here to count and then recount them again. if you see my image i show the outcome i need. i also thought of creating a refence to my main table for just rehires but i am trying to stay on one table but will have to do what works. Thanks in advance for the help.
Solved! Go to Solution.
Hi @ZURC_NAHOJ,
I am not sure how it will returns the data. However could ypu please try the below meassure to get distinct employee data. If possible could you please share the sample dataset so that I will get exact DAX.
Ending Headcount =
CALCULATE (
DISTINCTCOUNT ( 'V_EP_PR_EMP_ALL_FACT'[EMPNO] ),
FILTER (
'V_EP_PR_EMP_ALL_FACT',
'V_EP_PR_EMP_ALL_FACT'[DATE_HIRED] <= MAX ( 'Date'[Date] )
&& (
ISBLANK ( 'V_EP_PR_EMP_ALL_FACT'[TERMINATION_DATE] )
|| 'V_EP_PR_EMP_ALL_FACT'[TERMINATION_DATE] > MAX ( 'Date'[Date] )
|| 'V_EP_PR_EMP_ALL_FACT'[PREVIOUS_TERMINATION_DATE] > MAX ( 'Date'[Date] )
)
)
)
Thanks,
If you found this solution helpful, please consider giving it a Like👍 and marking it as Accepted Solution✔. This helps improve visibility for others who may be encountering/facing same questions/issues.
Hi @ZURC_NAHOJ ,
Thank you for reaching out to the Microsoft Community Forum.
Ending Headcount =
CALCULATE(
DISTINCTCOUNT('V_EP_PR_EMP_ALL_FACT'[EMPNO]),
FILTER(
'V_EP_PR_EMP_ALL_FACT',
'V_EP_PR_EMP_ALL_FACT'[DATE_HIRED] <= MAX('Date'[Date]) &&
(
ISBLANK('V_EP_PR_EMP_ALL_FACT'[TERMINATION_DATE]) ||
'V_EP_PR_EMP_ALL_FACT'[TERMINATION_DATE] >= MIN('Date'[Date])
)
)
)
If my response has resolved your query, please mark it as the Accepted Solution to assist others. Additionally, a 'Kudos' would be appreciated if you found my response helpful.
Thank you
Hi @ZURC_NAHOJ, Please try the below measure:
Ending Headcount =
CALCULATE(
DISTINCTCOUNT(V_EP_PR_EMP_ALL_FACT[EMPNO]),
FILTER(
V_EP_PR_EMP_ALL_FACT,
V_EP_PR_EMP_ALL_FACT[DATE_HIRED] <= MAX('Date'[Date]) &&
(
ISBLANK(V_EP_PR_EMP_ALL_FACT[TERMINATION_DATE]) ||
V_EP_PR_EMP_ALL_FACT[TERMINATION_DATE] > MAX('Date'[Date])
)
)
)
If this post helps to answer your question, please consider accepting it as a solution so others can find it more quickly when they face a similar challenge.
Proud to be a Microsoft Fabric community super user
Let's Connect on LinkedIn
Subscribe to my YouTube channel for Microsoft Fabric and Power BI updates.
Hi @ZURC_NAHOJ,
I am not sure how it will returns the data. However could ypu please try the below meassure to get distinct employee data. If possible could you please share the sample dataset so that I will get exact DAX.
Ending Headcount =
CALCULATE (
DISTINCTCOUNT ( 'V_EP_PR_EMP_ALL_FACT'[EMPNO] ),
FILTER (
'V_EP_PR_EMP_ALL_FACT',
'V_EP_PR_EMP_ALL_FACT'[DATE_HIRED] <= MAX ( 'Date'[Date] )
&& (
ISBLANK ( 'V_EP_PR_EMP_ALL_FACT'[TERMINATION_DATE] )
|| 'V_EP_PR_EMP_ALL_FACT'[TERMINATION_DATE] > MAX ( 'Date'[Date] )
|| 'V_EP_PR_EMP_ALL_FACT'[PREVIOUS_TERMINATION_DATE] > MAX ( 'Date'[Date] )
)
)
)
Thanks,
If you found this solution helpful, please consider giving it a Like👍 and marking it as Accepted Solution✔. This helps improve visibility for others who may be encountering/facing same questions/issues.
Hello @ZURC_NAHOJ
try this measure
Ending Headcount =
CALCULATE(
[_Measure'Total Employees],
FILTER(
'V_EP_PR_EMP_ALL_FACT',
(
'V_EP_PR_EMP_ALL_FACT'[DATE_HIRED] <= MAX('Date'[Date]) &&
(
ISBLANK('V_EP_PR_EMP_ALL_FACT'[TERMINATION_DATE]) ||
'V_EP_PR_EMP_ALL_FACT'[TERMINATION_DATE] >= MIN('Date'[Date])
)
)
||
(
NOT(ISBLANK('V_EP_PR_EMP_ALL_FACT'[REHIRE_DATE])) &&
'V_EP_PR_EMP_ALL_FACT'[REHIRE_DATE] <= MAX('Date'[Date])
)
)
)
Thanks,
Pankaj Namekar | LinkedIn
If this solution helps, please accept it and give a kudos (Like), it would be greatly appreciated.
i still show that employee listed as part of the end head count in months where they are not here.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
81 | |
76 | |
61 | |
37 | |
33 |
User | Count |
---|---|
99 | |
56 | |
50 | |
42 | |
40 |