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
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
v-yetao1-msft
Community Support
Community Support

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
v-yetao1-msft
Community Support
Community Support

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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors