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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
lnayak
Frequent Visitor

Use a measure 'Active Unique Headcount' using SUMX function.

HeadCount = VAR selectedDate=
MAX('Calendar'[Date]
RETURN
SUMX('EDE'[Worker #],
VAR WorkerStartDate = ('EDE'[MinStartDate])
VAR WorkerEndDate = ('EDE'[MaxEndDate])
RETURN IF ( WorkerStartDate<=selectedDate && OR (WorkerEndDate>=selectedDate, WorkerEndDate=BLANK(),1,0))
 
Used this function but am not getting the result.
Please help!
 
Thanks in advance
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @lnayak 

Based on your formula, I created a simple sample.

Original data :

Ailsamsft_0-1645685403134.png

Then use the formula you provided . I modified it to return the value 1 or 0 .

HeadCount =
VAR selectedDate=MAX('Calendar'[Date])
VAR _WorkerStartDate= SELECTEDVALUE(EDE[MinStartDate])
VAR _WorkerEndDate = SELECTEDVALUE(EDE[MaxEndDate])
RETURN IF ( _WorkerStartDate<=selectedDate && _WorkerEndDate>=selectedDate,1,0)

Then create a measure to count the total value .

count = SUMX('EDE',[HeadCount])

The final result is as shown :

Ailsamsft_1-1645685403137.pngAilsamsft_2-1645685403140.png

I have attached my pbix file , you can refer to it .

 

Best Regard

Community Support Team _ Ailsa Tao

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

7 REPLIES 7
Anonymous
Not applicable

Hi @lnayak 

Based on your formula, I created a simple sample.

Original data :

Ailsamsft_0-1645685403134.png

Then use the formula you provided . I modified it to return the value 1 or 0 .

HeadCount =
VAR selectedDate=MAX('Calendar'[Date])
VAR _WorkerStartDate= SELECTEDVALUE(EDE[MinStartDate])
VAR _WorkerEndDate = SELECTEDVALUE(EDE[MaxEndDate])
RETURN IF ( _WorkerStartDate<=selectedDate && _WorkerEndDate>=selectedDate,1,0)

Then create a measure to count the total value .

count = SUMX('EDE',[HeadCount])

The final result is as shown :

Ailsamsft_1-1645685403137.pngAilsamsft_2-1645685403140.png

I have attached my pbix file , you can refer to it .

 

Best Regard

Community Support Team _ Ailsa Tao

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

lnayak
Frequent Visitor

Hi,

 

Let me explain what am looking for am trying to work on headcount formula and if sumx doesn't work i need to change it to distinct count. can someone help me out here please?

 

lnayak
Frequent Visitor

Hi Tamerj1,

 

The date filter in report would just be from the calendar.

Hi @lnayak 
Yes

tamerj1
Super User
Super User

Hi @lnayak 

the first argument of SUMX is a table not a column. Besides no need to store column value in a variable just start with IF directly. But do you have to use SUMX?

Hi @tamerj1 

 

Yes, I used table within SUMX. Yes, i want to use this function to know if i get the result.

 

Thanks,

Laxmi 

You should if there is no other date filter on your visual

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.