Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more
Hello,
Looking for some help with a DAX formula. If you see the image below I am taking the distinct count of the employee_code field to obtain the number of employees per month. However, I also need to show the last trailing 12 months as an average of the distinct counts. How would I go about doing this in DAX?
I can get a distinct count for the last 12 months using the formula below, but it needs to be an average and not a count.
Head Count LTM = CALCULATE(DISTINCTCOUNT(PaycomHours[Employee_Code]),DATESINPERIOD ('edw dimDate'[Date],MAX ( 'edw dimDate'[Date]),-12,MONTH))
Thank you!!
Solved! Go to Solution.
@PeteDTG , Try a measure like
CALCULATE(averageX(values('edw dimDate'[month year]), calculate(DISTINCTCOUNT(PaycomHours[Employee_Code]))),DATESINPERIOD ('edw dimDate'[Date],MAX ( 'edw dimDate'[Date]),-12,MONTH))
Hey @PeteDTG ,
Please try using this :-
Avg of Head Count LTM = CALCULATE(AVERAGEX(PaycomHours,DISTINCTCOUNT(PaycomHours[Employee_Code])),DATESINPERIOD
('edw dimDate'[Date],MAX ( 'edw dimDate'[Date]),-12,MONTH))
Hey @PeteDTG ,
Please try using this :-
Avg of Head Count LTM = CALCULATE(AVERAGEX(PaycomHours,DISTINCTCOUNT(PaycomHours[Employee_Code])),DATESINPERIOD
('edw dimDate'[Date],MAX ( 'edw dimDate'[Date]),-12,MONTH))
You are awesome, thank you so much! Didn't think to use AVERAGEX! 🙂
@PeteDTG , Try a measure like
CALCULATE(averageX(values('edw dimDate'[month year]), calculate(DISTINCTCOUNT(PaycomHours[Employee_Code]))),DATESINPERIOD ('edw dimDate'[Date],MAX ( 'edw dimDate'[Date]),-12,MONTH))
Thank you so much!! 😁
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 8 | |
| 5 | |
| 4 | |
| 3 | |
| 3 |
| User | Count |
|---|---|
| 24 | |
| 12 | |
| 11 | |
| 9 | |
| 8 |