Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Dear Folk,
Please help me i am trying to calculate the headcount from the start date to the last date of the selected year and month.
kindly check the below DAX function I have used.
for Working count:-
The above table is showing working MTD head count but in august which is the current month and the total is showing different.
Hi @Anonymous ,
It is suggested to create a seperate year and month table for the slicer.
You can create a yearmonth table like
YearMonth =
DISTINCT (
SELECTCOLUMNS (
'Date_Table',
"Year", YEAR ( [Date] ),
"Month", MONTH ( [Date] )
)
)
Then create the Working_MTD measure like
Working_MTD =
VAR _year =
SELECTEDVALUE ( YearMonth[Year] )
VAR _month =
SELECTEDVALUE ( YearMonth[Month] )
RETURN
CALCULATE (
[empCount],
FILTER ( 'Employee Dump', [STATUS] = "Working" ),
FILTER (
'Date_Table',
[Date] <= EOMONTH ( DATE ( _year, _month, 1 ), 0 )
&& [Date] >= MIN ( 'Date_Table'[Date] )
)
)
Best Regards,
ShundaSteph
Hi @Anonymous ,
It is suggested to create a seperate year and month table for the slicer.
I appreciate it if someone helps me.
@Anonymous , can share the logic for MinDate and Enddate
Also, check if these types of formulas can help
MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))
MTD =
var _max = if(isfiltered('Date'),MAX( 'Date'[Date]) , today())
var _min = eomonth(_max,-1)+1 ,
return
CALCULATE([net] ,DATESBETWEEN('Date'[Date],_min,_max))
This Month =
var _max = eomonth(if(isfiltered('Date'),MAX( 'Date'[Date]) , today()),0)
var _min = eomonth(_max,-1)+1 ,
return
CALCULATE([net] ,DATESBETWEEN('Date'[Date],_min,_max))
Please find below for minDate & endDate logic.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 38 | |
| 38 | |
| 37 | |
| 28 | |
| 28 |
| User | Count |
|---|---|
| 124 | |
| 89 | |
| 73 | |
| 66 | |
| 65 |