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
yosemite
Helper III
Helper III

LOOKUPVALUE - Need Help

Hello,

 

I need to perform a look up of Table1[Column1] in Table 2[Column1] and return values that do not exist in Table1[Column1].

 

Appreciate any help.

 

Thank you.

2 ACCEPTED SOLUTIONS

Hi @yosemite ,

 

Take a look at this file: Download PBIX 

 

Basically I grouped the values per week and joined with a left anti and filtered nulls.

Capture.PNG

 

 

Did I answer your question? Mark my post as a solution!
Ricardo



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



View solution in original post

@yosemite ,

 

Check this new file: Download PBIX 

 

Take a look at the week_missing table on Power Query.

 

Did I answer your question? Mark my post as a solution!
Ricardo



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



View solution in original post

18 REPLIES 18
nandukrishnavs
Super User
Super User

@yosemite 

 

I would recommend you to use the merge option (right outer) in Edit Query instead of DAX.

 

https://docs.microsoft.com/en-us/power-bi/desktop-shape-and-combine-data#combine-queries

https://radacad.com/choose-the-right-merge-join-type-in-power-bi



Did I answer your question? Mark my post as a solution!
Appreciate with a kudos
🙂

 

 


Regards,
Nandu Krishna

Hello @nandukrishnavs - Thanks so much! I was able to obtain a list of what doesn't exist in Table1 by using Right Anti. 

 

What I'm trying to do is to get a list of Employee Name that does not exist in Table1 by 'Week'. Table2 contains distinct employee and does not have a 'Week' column. 

 

TABLE1

WeekEmployee Name
Week 1Employee1
Week 1Employee2
Week 1Employee3
Week 1Employee4
Week 1Employee5
Week 2Employee 1
Week 2Employee 3
Week 2Employee 5
Week 3Employee 1

 

Table 2

Employee Name
Employee1
Employee2
Employee3
Employee4
Employee5

 

Any help is appreciated!

Hi @yosemite ,

 

Try this one:

 

Capture.PNG

 

Did I answer your question? Mark my post as a solution!
Ricardo



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



This didn't work. Thanks for trying.

 

Since my goal is to get a list of employees that do not exist in Table1 by Week, I would like my merged table to return the following:

 

WeekEmployee Name
Week 2Employee2
Week 2Employee4
Week 3Employee2
Week 3Employee3
Week 3Employee4
Week 3Employee5

 

Hi @yosemite ,

 

Take a look at this file: Download PBIX 

 

Basically I grouped the values per week and joined with a left anti and filtered nulls.

Capture.PNG

 

 

Did I answer your question? Mark my post as a solution!
Ricardo



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



@camargos88 - Thank you so much. I feel like I'm getting closer.

 

Could you walk me through how you 'Added Custom' (Step 6) and  joined with a left anti?

@yosemite ,

First you group all your rows by week and created a new column with a grouped table column.

 

Table.Join(
#"Table (2)", "Employee Name",
Table.RenameColumns([Rows],
{"Employee Name", "EmployeeName"}),
"EmployeeName", JoinKind.LeftAnti)

 

Did I answer your question? Mark my post as a solution!
Ricardo



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



@camargos88 I got to this part.  See, my table1 and table2 contains many columns.  For simplicity, I only posted 1 and 2 columns for the table.

 

What I'm trying to understand right now is do I list all the column names in table1 and table 2? See highlighted text in red. Also, where did you get 'EmployeeName' when the column names in both tables in PBIX are 'Employee Name'. 

 

Table1.Join(
#"Table2", "Employee Name", Can I include more columns from Table 2?
Table1.RenameColumns([Rows],
{"Employee Name", "EmployeeName"}), Can I include more columns from Table 1?
"EmployeeName", JoinKind.LeftAnti)

@yosemite ,

 

Doesn't matter how many columns you have. This code just join both tables using the key column "Employee Name".

The "EmployeeName" is just a renamed column to join it.

 

Ricardo



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



@camargos88 

 

I'm getting an error Expression.Error: The name 'RollCallList_Test.RenameColumns' wasn't recognized. Make sure it's spelled correctly. 

 

= Table.AddColumn(#"Grouped Rows", "Custom", each Table.Join(
#"ABCEmployees", "EMPLOYEE_ID",
RollCallList_Test.RenameColumns([Rows],
{"EmployeeNo", "EmployeeName"}),
"EmployeeName", JoinKind.LeftAnti))

@yosemite ,

 

Table.RenameColumns is a function, you can change it. You just change the parameters of it.

 

= Table.AddColumn(#"Grouped Rows", "Custom", each Table.Join(
#"ABCEmployees", "EMPLOYEE_ID",
Table.RenameColumns([Rows],
{"EmployeeNo", "EmployeeName"}),
"EmployeeName", JoinKind.LeftAnti))



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



@camargos88 You are awesome! Thanks for your help.

Hello @camargos88 - Just checking if you have an idea why I am not getting any 'null' EmployeeNo after using JoinKind.LeftAnti so I'm unable to filter it out. 

 

I'm going back to your steps and want to make sure I didn't miss anything. This is what I did to group the week:

  • Highlight Week column
  • Transform > Group By 
  • Basic > New column name: Type Rows > Operation: All Rows

Then I successfully added the Custom column with the code below.

 

= Table.AddColumn(#"Grouped Rows", "Custom", each Table.Join(
#"ABCEmployees (2)", "EmployeeNo", Table.RenameColumns([Rows], {"EmployeeNo", "EmpName"}),
"EmpName", JoinKind.LeftAnti))

 

The only problem is when I removed Rows column and expanded Custom column, I didn't find any null EmployeeNo. 

@yosemite ,

 

You should get a return with 3 columns:

1 week column

2 employee num (1 from left side / 1 from right side).

 

If you don't have any nulls it's likely you don't have any employee for this week...it's sounds weird

Can you provide some samples of this week ?

 

Ricardo



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



@camargos88  Although I didn't have to filter out 'null' values, it worked on this simple dataset; see link below. 

 

My dataset has thousands of employees, and they are not being filtered out. I followed all the steps. 😣

 

Yosemite_v1.pbix 

@yosemite ,

 

Check this new file: Download PBIX 

 

Take a look at the week_missing table on Power Query.

 

Did I answer your question? Mark my post as a solution!
Ricardo



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



Thank you very much! @camargos88 

 

You've been extremely helpful.

@yosemite 

 

Another alternate approach.

 

Table1

Week Employee Name
Week 1Employee1
Week 1Employee2
Week 1Employee3
Week 1Employee4
Week 1Employee5
Week 2Employee1
Week 2Employee3
Week 2Employee5
Week 3Employee1

 

Table2

 

Employee Name
Employee1
Employee2
Employee3
Employee4
Employee5

 

relationship.JPG

 

 

Present = 
var _count=CALCULATE(COUNT(Table1[Employee Name]))
var _result=IF(ISBLANK(_count),0,_count)
return _result

 

 

Create a matrix visual.

sett.JPG

 

newoutput.JPG

 

Now you can export this visual. You will get the below table.

 

z.JPG

Now you can filter zero.

 



Did I answer your question? Mark my post as a solution!
Appreciate with a kudos
🙂

 

 

 

 

 


Regards,
Nandu Krishna

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.

Top Solution Authors