Forum Discussion
Per Capita cal
Hi, I want to calculate per capita amount for employees. For one employee multiple pay codes are generated for each month.
Per capita calculation is attached below in Excel screenshots. How do I implement this Power BI DAX?
I need hep on this to calculate, please. Thank you.
Sample Data:
| Payroll INC | Period | YearMonth | Year | Month | Employee name | Employee ID | Type of emp | Amount | Paycode |
| 1/4/2022 | 2022/04 | 202204 | 2022 | 4 | A | 25890 | Local | 29000 | Y78IL |
| 1/4/2022 | 2022/04 | 202204 | 2022 | 4 | A | 25890 | Local | 5900 | O09PJ |
| 1/4/2022 | 2022/04 | 202204 | 2022 | 4 | A | 25890 | Local | 5689 | PO89U |
| 5/5/2022 | 2022/05 | 202205 | 2022 | 5 | A | 25890 | Local | 29000 | U8IOP |
| 5/5/2022 | 2022/05 | 202205 | 2022 | 5 | A | 25890 | Local | 2589 | P09NB |
| 8/6/2022 | 2022/06 | 202206 | 2022 | 6 | A | 25890 | Local | 29000 | TW76A |
| 8/6/2022 | 2022/06 | 202206 | 2022 | 6 | A | 25890 | Local | 7825 | EU76B |
| 2/1/2023 | 2023/01 | 202301 | 2023 | 1 | B | 57698 | Contract | 35000 | YR09JT |
| 2/1/2023 | 2023/01 | 202301 | 2023 | 1 | B | 57698 | Contract | 5000 | YT64YU |
| 1/2/2023 | 2023/02 | 202302 | 2023 | 2 | B | 57698 | Contract | 35000 | AS8795 |
| 1/2/2023 | 2023/02 | 202302 | 2023 | 2 | B | 57698 | Contract | 6500 | JGH670 |
| 1/2/2023 | 2023/02 | 202302 | 2023 | 2 | B | 57698 | Contract | 7815 | KJ97GH |
| 2/3/2023 | 2023/03 | 202303 | 2023 | 3 | B | 57698 | Contract | 35000 | ST53GH |
| 2/3/2023 | 2023/03 | 202303 | 2023 | 3 | B | 57698 | Contract | 983.3 | BV87YU |
| 2/4/2023 | 2023/04 | 202304 | 2023 | 4 | B | 57698 | Contract | 35000 | NB84KJ |
| 2/5/2023 | 2023/05 | 202305 | 2023 | 5 | B | 57698 | Contract | 35000 | AQ23LP |
| 1/6/2023 | 2023/06 | 202306 | 2023 | 6 | B | 57698 | Contract | 35000 | ZX32FR |
| 1/6/2023 | 2023/06 | 202306 | 2023 | 6 | B | 57698 | Contract | 7985.6 | AS19FG |
| 2/7/2023 | 2023/07 | 202307 | 2023 | 7 | B | 57698 | Contract | 35000 | AB46JY |
| 2/11/2023 | 2023/11 | 202311 | 2023 | 11 | C | 78965 | Local | 41562.5 | AH80YU |
4 Replies
- AnonymousNot applicable
Hi Junayet_Rahaman ,
I'm sorry I don't quite understand the logic of the Average People column and why Employee C is only eleven months, can you explain this in more detail?
Best Regards,
Neeko Tang
- Junayet_RahamanFrequent Visitor
Hi Neeko Tang,
Employee C is only 11 because in 2023 year 11 months are ongoing month. So employee C is having amount only for 11 (Nov) so the count for this year is 1. It will divide 1/11. If Employee C was present 2 months then it would divided by 2/11. Please let me know if there is still confusion. Thanks for your support.
- AnonymousNot applicable
Hi Junayet_Rahaman ,
We can create a table.
Table 2 = ADDCOLUMNS(CALENDAR(DATE(2022,1,1),DATE(2023,12,31)),"month",MONTH([Date]))We can create measures.
Measure 2 = var _total=IF(MAX('Table'[Year])<YEAR(TODAY()),12,MONTH(TODAY())) var _table1=SUMMARIZE(ALL('Table'),'Table'[Employee name],'Table'[Month]) var _month=COUNTROWS(FILTER(_table1,'Table'[Employee name]=MAX('Table'[Employee name]) && [Month] in VALUES('Table 2'[month]))) return DIVIDE(_month,_total,0)Measure 3 = var _a= CALCULATE(SUM('Table'[Amount]),ALL('Table')) var _b=SUMX(VALUES('Table'[Employee name]),[Measure 2]) return _a * _bBest Regards,
Neeko Tang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.