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
bboobe
Helper I
Helper I

NEED HELP Compare columns in two tables and Find Difference

Hi Experts 

I am trying to compare a master file with daily employee file 

In Master table, I have unique department code for each Project code  

In Employee table, I have more than one department code for a single project as the department is tagged incorrectly by the employee level.

I am stuck with this now. Please advise.

 

Below is the Sample - 

Employee Table Project ID - 12345 

Employee Table Department ID - 100

Master table Departement id - 101 

Result - False

1 ACCEPTED SOLUTION
nandukrishnavs
Super User
Super User

@bboobe 

 

Master Table

Project IDDepartment ID
1200101
1201120

 

EmployeeTable

Project IDEmployee IDDepartment ID
12001100
12012120

 

Status Check = 
var _selectedDepartment= CALCULATE(SELECTEDVALUE(EmployeeTable[Department ID]))
var _selectedProjectId= CALCULATE(SELECTEDVALUE(EmployeeTable[Project ID]))
var _actualDepartment= CALCULATE(LOOKUPVALUE(MasterTable[Department ID],MasterTable[Project ID],_selectedProjectId))
var _result= IF(_actualDepartment=_selectedDepartment,TRUE(),FALSE())
return _result

 

Capture.JPG 

If this is not working, please share your sample tables with 5 rows and expected output.



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


Regards,
Nandu Krishna

View solution in original post

4 REPLIES 4
nandukrishnavs
Super User
Super User

@bboobe 

 

Master Table

Project IDDepartment ID
1200101
1201120

 

EmployeeTable

Project IDEmployee IDDepartment ID
12001100
12012120

 

Status Check = 
var _selectedDepartment= CALCULATE(SELECTEDVALUE(EmployeeTable[Department ID]))
var _selectedProjectId= CALCULATE(SELECTEDVALUE(EmployeeTable[Project ID]))
var _actualDepartment= CALCULATE(LOOKUPVALUE(MasterTable[Department ID],MasterTable[Project ID],_selectedProjectId))
var _result= IF(_actualDepartment=_selectedDepartment,TRUE(),FALSE())
return _result

 

Capture.JPG 

If this is not working, please share your sample tables with 5 rows and expected output.



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


Regards,
Nandu Krishna

Thank you @nandukrishnavs  It worked. 🙂 

az38
Community Champion
Community Champion

@bboobe 

there is not full data model but it may looked like

Measure = 
var _curDepartment = MAX('Master'[Departement id])

RETURN
IF(
CALCULATE(COUNTROWS('Employee'), FILTER(ALL('Employee'), 'Employee'[Departement id]=_curDepartment) ) > 0, 
TRUE(), 
FALSE()
)

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Thank you for taking time and responding @az38 . I tried the above measure and it did not work. Below is the screenshot from the visual.

 

 

The comparison has to be done on employee level. and i need to view only the employee ids with incorrect department.  

Capture.JPG

 

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.