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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
nareshr89
Helper II
Helper II

Headcount Calculation

I need help with a scenario with the headcount, where the numbers given under Opening is picked as is at monthly level but when its quarterly level we need to maintain the Jan data as Opening and Closing headcount to be last month of the period.

 

Ex - Q1 -> Opening will be of Jan and Closing numbers will be of Mar.

 

Below is the DAX used by me which sums up when selecting Q1, instead i need the above logic to work. Sample excel file attached.

 

F_OpeningHC =

var yr = SELECTEDVALUE(Dim_time[Year])
var ml = SELECTEDVALUE(Dim_time[MonthLoad])

Return
CALCULATE(SUM(sf_CSS[hc_opening]),sf_CSS[sf_year]=yr,sf_CSS[sf_month_load]=ml)

 

Looking for the help to build this logic. @tamerj1

2 ACCEPTED SOLUTIONS
tamerj1
Community Champion
Community Champion

Hi @nareshr89 

Apologies for the late reply. I was out of office all day. 
Please try by replacing SELECTEDVALUE ( Dim_time[MonthLoad] ) with MIN ( Dim_time[MonthLoad] ) for Opening HC and MAX ( Dim_time[MonthLoad] ) for Closing HC

View solution in original post

nareshr89
Helper II
Helper II

Thanks for reverting @tamerj1.

Found the solution using similar logic for the YearMonth ID.

 

F_OpeningHC =
var yr = SELECTEDVALUE(Dim_time[Year])
var ml = SELECTEDVALUE(Dim_time[MonthLoad])
VAR yearmonth = CALCULATE(MIN(sf_CSS[time_id]),sf_CSS[sf_year]=yr,sf_CSS[sf_month_load]=ml)

 

Return
CALCULATE(SUM(sf_CSS[hc_opening]),sf_CSS[sf_year]=yr,sf_CSS[sf_month_load]=ml,sf_CSS[time_id]= yearmonth)

 

 

F_ClosingHC =

var yr = SELECTEDVALUE(Dim_time[Year])
var ml = SELECTEDVALUE(Dim_time[MonthLoad])
VAR yearmonth = CALCULATE(MAX(sf_CSS[time_id]),sf_CSS[sf_year]=yr,sf_CSS[sf_month_load]=ml)

Return
CALCULATE(SUM(sf_CSS[hc_closing]),sf_CSS[sf_year]=yr,sf_CSS[sf_month_load]=ml,sf_CSS[time_id]=yearmonth)

View solution in original post

2 REPLIES 2
nareshr89
Helper II
Helper II

Thanks for reverting @tamerj1.

Found the solution using similar logic for the YearMonth ID.

 

F_OpeningHC =
var yr = SELECTEDVALUE(Dim_time[Year])
var ml = SELECTEDVALUE(Dim_time[MonthLoad])
VAR yearmonth = CALCULATE(MIN(sf_CSS[time_id]),sf_CSS[sf_year]=yr,sf_CSS[sf_month_load]=ml)

 

Return
CALCULATE(SUM(sf_CSS[hc_opening]),sf_CSS[sf_year]=yr,sf_CSS[sf_month_load]=ml,sf_CSS[time_id]= yearmonth)

 

 

F_ClosingHC =

var yr = SELECTEDVALUE(Dim_time[Year])
var ml = SELECTEDVALUE(Dim_time[MonthLoad])
VAR yearmonth = CALCULATE(MAX(sf_CSS[time_id]),sf_CSS[sf_year]=yr,sf_CSS[sf_month_load]=ml)

Return
CALCULATE(SUM(sf_CSS[hc_closing]),sf_CSS[sf_year]=yr,sf_CSS[sf_month_load]=ml,sf_CSS[time_id]=yearmonth)

tamerj1
Community Champion
Community Champion

Hi @nareshr89 

Apologies for the late reply. I was out of office all day. 
Please try by replacing SELECTEDVALUE ( Dim_time[MonthLoad] ) with MIN ( Dim_time[MonthLoad] ) for Opening HC and MAX ( Dim_time[MonthLoad] ) for Closing HC

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.