Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

YTD Monthly Headcount AVG

Hello,

 

I currently am trying to get YTD Monthly Headcount AVG, as well as, Monthly HC Avg for the previous 2 months. However, my monthly HC is calculated by this formula:

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

RETURN

SUMX('employees',
VAR employeeStartDate = [startDate]
VAR employeeEndDate = [termDate]
RETURN IF(employeeStartDate<= selectedDate && OR(employeeEndDate>=selectedDate, employeeEndDate=BLANK() ),1,0)
)"
 
Sorry I don't have any data to share. Please let me know your suggestions ASAP. Thank you!

2 Replies

  • Anonymous , Not very clear. But Take YTD of headcount and divide my month year distinct count

     

    YTD Sales = divide(CALCULATE([Headcount],DATESYTD('Date'[Date])),CALCULATE(distinctcount('Date'[Month Year]),DATESYTD('Date'[Date])))

     

    To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :
    https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
    https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi

    Appreciate your Kudos.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi amitchandak,

       

      Thank you for your solution! So it's almost what I need. I have attached a photo of my graph currently. The data label numbers are the ending headcount for each month, so I need the average for YTD for each month. So for like August it would add up all of the ending headcounts for the previous months and then divide by 8. Thank you for your help!