Power BI Measure to combine Headcount by Month, Year and Company selected by Slicer

WxShady13

Board Regular
Joined
Jul 24, 2018
Messages
185
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
Code:
HeadcountbyMonth =
CALCULATE(
    SUM(TermCategoryTurnoverPercentage[Headcount]),
    ALLSELECTED(TermCategoryTurnoverPercentage[Category]),
    Filter(
        ALLSELECTED(TermCategoryTurnoverPercentage[Date]),
        TermCategoryTurnoverPercentage[Date]>=MIN(TermCategoryTurnoverPercentage[Date]) &&
        TermCategoryTurnoverPercentage[Date]<=Max(TermCategoryTurnoverPercentage[Date])
),
VALUES(DATE(YEAR(TermCategoryTurnoverPercentage[Date]), MONTH(TermCategoryTurnoverPercentage[Date]),1))
)

I have a table that has Company (Category), Term Category (Involuntary/Voluntary) and Hourly/Salaried. I need to create a measure that will total the headcount by whatever criteria is selected by the various slicers I have on the page (i.e. Date range, Category, Term Category or Hourly/Salaried). The data table is setup similar to what is shown below. I have duplicates for month/company because I need to have a row for Hourly/Involuntary, Hourly/Voluntary, Salaried/Involuntary and Salaried/Voluntary. So another challenge is to divide by 2 the headcount by month. Any help is greatly appreciated,

CategoryTerm CategoryYearTerm MonthDateHourly/SalariedTotalHeadcount
Company XInvoluntary2024Jan1/1/2024Hourly152386
Company XInvoluntary2024Jan1/1/2024Salaried351185
Company XVoluntary2024Jan1/1/2024Hourly992386
Company XVoluntary2024Jan1/1/2024Salaried101185
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"

Forum statistics

Threads
1,223,885
Messages
6,175,181
Members
452,615
Latest member
bogeys2birdies

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top