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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Nicolachan0416
New Member

DAX count wrongly with a slicer

I am trying to calculate the headcount from a worksheet named - Master_Active2 and the slicer is applied the time period from a worksheet named - Master_In_Out.

 

As a result, i cannot find the correct headcount from the below formula: 

Nicolachan0416_0-1739932508227.png

Could you help to let me know what would be the reason behind? Thanks.

1 ACCEPTED SOLUTION
bhanu_gautam
Super User
Super User

@Nicolachan0416 , Try using

Headcount =
CALCULATE(
COUNT(Master_Active2[Subsidiary Employee ID]),
USERELATIONSHIP(Master_Active2[Period_Month], Master_In_Out[Period_Month]),
FILTER(
Master_In_Out,
Master_In_Out[Period_Year] = SELECTEDVALUE(Master_In_Out[Period_Year])
)
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @Nicolachan0416 ,

 

Whether the advice given by bhanu_gautam  has solved your confusion, if the problem has been solved you can mark the reply for the standard answer to help the other members find it more quickly. If not, please 

provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Refer to:

How to provide sample data in the Power BI Forum

How to Get Your Question Answered Quickly

 

Best Regards,

Neeko Tang

bhanu_gautam
Super User
Super User

@Nicolachan0416 , Try using

Headcount =
CALCULATE(
COUNT(Master_Active2[Subsidiary Employee ID]),
USERELATIONSHIP(Master_Active2[Period_Month], Master_In_Out[Period_Month]),
FILTER(
Master_In_Out,
Master_In_Out[Period_Year] = SELECTEDVALUE(Master_In_Out[Period_Year])
)
)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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