cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
PiotrCalka
Regular Visitor

Help with DAX to deduct data from two tables based on ID& Date

Hello,

I have two tables:

- Annual Plans with columns: project_id, employee_id, Date 

- Leaves with columns: employee_id, Date 

There is no direct relatinoship between tables. Both have realtion to Calendar table and ID employee table.

I am counting DISTINCTCOUNT(Annual_Plans[employee_id]) - to see number of employees,

I need to see number of employees dedecuted by those who are on break (Leaves), so Annual Plans - Leaves per project id.
It needs to be sth like: If dates and employee_id from two tables equals then deduct Annuals Plans - Leave.
I would be gratefull for tips how to do it in DAX.

 

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @PiotrCalka 

please try

=
COUNTROWS (
EXCEPT ( VALUES ( Annual_Plans[employee_id] ), VALUES ( Leaves[employee_id] ) )
)

View solution in original post

4 REPLIES 4
PiotrCalka
Regular Visitor

Thank you all,

Thank you @tamerj1 this work as I wanted.

v-polly-msft
Community Support
Community Support

Hi @PiotrCalka ,

Could you please provide more details? Your pbix file without privacy inforamtion and desired output with screenshots.

 

How to Get Your Question Answered Quickly 

 

Best Regards
Community Support Team _ Polly

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

 

tamerj1
Super User
Super User

Hi @PiotrCalka 

please try

=
COUNTROWS (
EXCEPT ( VALUES ( Annual_Plans[employee_id] ), VALUES ( Leaves[employee_id] ) )
)

lbendlin
Super User
Super User

Please provide sanitized sample data that fully covers your issue.
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
Please show the expected outcome based on the sample data you provided.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

Helpful resources

Announcements
November 2022 Update

Check it Out!

Click here to read more about the November 2022 updates!

Power BI Dev Camp Session 27

Ted's Dev Camp

This session walks through creating a new Azure AD B2C tenant and configuring it with user flows and custom policies.

Health and Life Sciences Power BI User Group

Health and Life Sciences Power BI User Group

Power BI specialists at Microsoft have created a community user group where customers in the provider, payor, pharma, health solutions, and life science industries can collaborate.