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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
lburgess
Helper II
Helper II

Select rows from table 2 that are not in table 1

I've been beating my head against the wall on this one for several days.  Hoping someone here can help.

 

I'm building a report against an onboarding application.  There are two primary lists involved.  "Onboarding Tasks" is a SPO list of all tasks involved in onboarding a new branch.  "Branch Onboarding Tasks" is a list of all tasks that have been scheduled for a specific branch.  New tasks are scheduled as parent tasks are completed, so the Branch Onboarding Tasks doesn't always have all of the tasks listed.  I'm trying to build a table in my report that contains all tasks from Onboarding Tasks that have not been scheduled for a given branch (i.e. the tasks don't exist in Branch Onboarding Tasks for that particular branch).

 

Sample data:

Onboarding Tasks

Task IDTask Name
1000Task 1
1010Task 2
1020Task 3

 

Branch Onboarding Tasks

Branch IDTask ID
12341000
12341010
56781000
99991000
99991010
99991020

 

For branch 1234, the table should contain 1 row - Task 1020 - Task 3

For branch 5678 it should contain 2 rows - Task 1010 - Task 2 and Tasks 1020 - Task 3

For branch 9999 it should contain no rows

 

If I were writing SQL for this, I'd get all task IDs for the given branch from Branch Onboarding Tasks, then get all rows from Onboarding Tasks where the Task ID is not in the list from the first table.  I tried a merge into a new table (several versions of the join), but with no success.

 

Any ideas would be greatly appreciated!!

2 ACCEPTED SOLUTIONS
Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

v-yangliu-msft
Community Support
Community Support

Hi  @lburgess ,

Here are the steps you can follow

1. Create measure.

Result = 
CALCULATE(SUM('Onboarding Tasks'[Task ID]),FILTER('Onboarding Tasks',NOT([Task ID]) in VALUES('Branch Onboarding Tasks'[Task ID])))

2. Result:

vyangliumsft_0-1629259156604.png

 

Best Regards,

Liu Yang

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

5 REPLIES 5
v-yangliu-msft
Community Support
Community Support

Hi  @lburgess ,

Here are the steps you can follow

1. Create measure.

Result = 
CALCULATE(SUM('Onboarding Tasks'[Task ID]),FILTER('Onboarding Tasks',NOT([Task ID]) in VALUES('Branch Onboarding Tasks'[Task ID])))

2. Result:

vyangliumsft_0-1629259156604.png

 

Best Regards,

Liu Yang

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

Ashish_Mathur
Super User
Super User

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Close but not quite.  My suspicion is the MAX in this measure is the issue.

 

Measure 2 = CALCULATE(max('Onboarding tasks'[Task Name]),FILTER(SUMMARIZE(Tasks,Tasks[Task ID],"ABCD",COALESCE(COUNTROWS('Branch onboarding tasks'),0)),[ABCD]=0))
 
The missing Task ID's may not be the max value.  My example may have thrown you off.  Here's a better example.
 

Sample data:

Onboarding Tasks

Task IDTask Name
1000Task 1
1010Task 2
1020Task 3

 

Branch Onboarding Tasks

Branch IDTask ID
12341000
12341020
56781000
99991000
99991010
99991020

 

For branch 1234, the table should contain 1 row - Task 1010 - Task 2

For branch 5678 it should contain 2 rows - Task 1010 - Task 2 and Tasks 1020 - Task 3

For branch 9999 it should contain no rows

Hi,

You have not tried my solution.  I plugged in your revised data into my PBI file and my result matches yours.

Untitled.png 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
VijayP
Super User
Super User

@lburgess 

I think that may not be possible in even in SQL because the join(merge) works based the similar columns in both tables and accordingly the data can be distributed to different rows. 

 




Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!


Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.