cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
PowerMyBI
Frequent Visitor

Filter between tables

Hi Power BI Community,

 

I am trying to sum and filter results between two tables. The result we are hoping to achieve is to sum the available hours in Table1 based on if the staff member is employed. I'm uncertain if I can do this in a calculated column or if I need to do so in a separate table.

 

Table1 (EndDate is empty if staff is stil currently employed)

StaffNameStartDate(d/mm/yy)EndDate(d/mm/yy)HoursAvailable
Sally13/04/201815/09/202040
Bob1/06/2019 35
Fred25/10/2020 37

 

Table2

RevenueTotalMonthCalculatedColumnOfAvailableHours
57500008/202075
55000009/202075
59200010/202072

 

Thanks!

1 ACCEPTED SOLUTION
amitchandak
Super User IV
Super User IV

@PowerMyBI , Create a new column in table 2

 

sumx(filter(Table1, Table1[start date] <= Table2[Month] && (isblank(Table1[EndDate]) || Table1[EndDate] >=Table2[Month])),[HoursAvailable])



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

View solution in original post

2 REPLIES 2
amitchandak
Super User IV
Super User IV

@PowerMyBI , Create a new column in table 2

 

sumx(filter(Table1, Table1[start date] <= Table2[Month] && (isblank(Table1[EndDate]) || Table1[EndDate] >=Table2[Month])),[HoursAvailable])



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

View solution in original post

Yes this worked perfectly thank you @amitchandak ! I see what I was doing wrong in my first attempts now. 

Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

April Update

Check it Out!

Click here to read more about the April 2021 Updates!

MBAS Carousel

Sign up for our May 4th event!

May the fourth be with you, join us online!

secondImage

The largest Power BI virtual conference

100+ sessions, 100+ speakers, Product managers, MVPs, and experts. All about Power BI. Attend online or watch the recordings.