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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
alan_joseph
Regular Visitor

Average of Monthly Distinct Headcounts

Hi,

 

I'm having trouble calculating the average monthly headcount of employees. My data has the employee number, month. I'm using the DISTINCTCOUNT formula on the employee number column to get the headcount, however i'm not able to get the monthly average. My data looks like this.

 

Employee NumberMonth
4572771/3/16
4196631/4/16
9680151/2/16
6205721/2/16
5223711/4/16
3457071/1/16
5846261/4/16
2263191/4/16
7519441/4/16
2880361/4/16
4179071/1/16
5786831/1/16
2406421/1/16
5629381/2/16
9119951/3/16
6250271/4/16
5223711/2/16
3457071/4/16
5846261/2/16
2263191/1/16

 

as per this data the month-wise headcount is as follows:

 

MonthDistinct Count of Employee Number
Jan5
Feb5
Mar2
Apr8

 

therefore my average monthly headcount would be the average of the four months' headcount which is 5. Can someone help me with the formula that can help me create a measure which gives this result.

 

 

TIA.

Alan.

1 ACCEPTED SOLUTION

Hi @alan_joseph,

 

For month-wise table: (Modeling -> new table)

 

HC_Month_wise = SUMMARIZECOLUMNS(HC[Years],HC[Months],HC[MonthsNo],"Headcount",DISTINCTCOUNT(HC[Employee Number])  )

Create calculated measure for AVG monthly:

 

AVG Monthly = CALCULATE(AVERAGE(HC_Month_wise[Headcount]),FILTER(all(HC_Month_wise), HC_Month_wise[Years]=max(HC_Month_wise[Years])  ))

Screenshot 2017-02-06 21.57.32.png

 

Please refer sample file and sample data

View solution in original post

5 REPLIES 5
Vvelarde
Community Champion
Community Champion

@alan_joseph

 

hi, you can obtain the result using AverageX

 

EmployeeNumberByMonth =
DIVIDE (
    AVERAGEX ( Table1, COUNT ( Table1[Employee Number] ) ),
    DISTINCTCOUNT ( Table1[Month] )
)

And like AverageX affect the performance you can use only in totals

 

EmployeeNumberByMonth =
IF (
    HASONEVALUE ( Table1[Month] ),
    DISTINCTCOUNT ( Table1[Employee Number] ),
    DIVIDE (
        AVERAGEX ( Table1, COUNT ( Table1[Employee Number] ) ),
        DISTINCTCOUNT ( Table1[Month] )
    )
)

 




Lima - Peru
tringuyenminh92
Memorable Member
Memorable Member

Hi @alan_joseph,

 

Are these 2 separated tables? Could you please show me your data model (table structures) ? so I could figure out correct solution.

And one concern that your month-wise headcount is 1 year or multiple years?

Hi @tringuyenminh92, thanks for your reply. The second table is the output i require after the calculations made on the first table. it is nothing but the distinct count of the employee numbers against each month. then i want the average of this column i.e. in this case (5+5+2+8)/4 months = 5 employees per month. 

 

in reality my data spans for more than 3 years. this  was just a sample i had shared. 


Hi @alan_joseph,

 

For month-wise table: (Modeling -> new table)

 

HC_Month_wise = SUMMARIZECOLUMNS(HC[Years],HC[Months],HC[MonthsNo],"Headcount",DISTINCTCOUNT(HC[Employee Number])  )

Create calculated measure for AVG monthly:

 

AVG Monthly = CALCULATE(AVERAGE(HC_Month_wise[Headcount]),FILTER(all(HC_Month_wise), HC_Month_wise[Years]=max(HC_Month_wise[Years])  ))

Screenshot 2017-02-06 21.57.32.png

 

Please refer sample file and sample data

This did not work for me.  Here are the results

pastedImage (1).png

 

To create the calculated column I used

AVG Monthly = CALCULATE(AVERAGE(HC_Month_wise[Headcount]),FILTER(all(HC_Month_wise), HC_Month_Wise[Year]=max(HC_Month_Wise[Year])  ))

 

 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.