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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Alex_Power_BI
Regular Visitor

Comparing if a value in one table can be found in another table through relationships

Hello,

 

I'm struggling to create a DAX measure solution for the following scenario:

 

We have employees that record hours in a virtual timecard system. This is a corporate dataset that I'm bringing into my Power BI data model. The managers in our department keep their own Excel sheets to assign their direct reports projects and to keep track of their assignments. I import their excel sheets into the data model and relate them to the dataset via Direct Query. I would like to create a measure that compares the projects for an employee on the manager assignement sheet to the projects employees record time against in the virtual time card system (and vice versa). I have example tables below simplifying the data.

 

The data tables in the data set include: 

Supervisor_Table

EmployeeSupervisorEmployee ID
AlexSarah101
BrianSarah102
ChrisSam103
DanSarah104
FrankSam

105

 

Resources

Employee IDCost CenterResource Code
101A12001
102A12002
103A22003
104A12004
105A22005

 

Hours

Resource CodeHoursActivity Code
200120W
200115X
20015Y
200218Z
200222W
200340X
20049Y
200431Z
200535Y

 

Activity

Activity CodeProject CodeProject Name
W31Project A
X31Project A
Y32Project B
Z33Project C

 

The manager assignment tracker table looks like:

Assignments

EmployeeEIDProject Name
Alex101Project A
Alex101Project B
Alex101Project C
Brian102Project A
Brian102Project C
Chris103Project A
Chris103Project C
Dan104Project C
Dan104Project A
Frank105Project B
Frank105Project A

 

The data model I built from these tables is depicted below:

Alex_Power_BI_0-1698956712827.png

 

 

The resulting tables I'd like to get are:
Result 1 (Comparing Manager Assignments to Timecard)

EmployeeEIDProject NameMatches Timecard?
Alex101Project ATRUE
Alex101Project BTRUE
Alex101Project CFALSE
Brian102Project ATRUE
Brian102Project BFALSE
Brian102Project CTRUE
Chris103Project ATRUE
Dan104Project CTRUE
Dan104Project AFALSE
Frank105Project BTRUE
Frank105Project AFALSE

 

Result 2 (Comparing Timecard projects to Manager Assignments)

EmployeeResource CodeHoursActivity CodeProject NameMatches Manager Assignment
Alex200120WProject ATRUE
Alex200115XProject ATRUE
Alex20015YProject BTRUE
Brian200218ZProject CTRUE
Brian200222WProject ATRUE
Chris200340XProject ATRUE
Dan20049YProject BFALSE
Dan200431ZProject CTRUE
Frank200535YProject BTRUE

 

Any help would be greatly appreciated. Thank you in advance!

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

Surprisingly tough.  Requires visual level measure filters.

 

lbendlin_0-1699128720820.png

 

 

View solution in original post

3 REPLIES 3
lbendlin
Super User
Super User

Surprisingly tough.  Requires visual level measure filters.

 

lbendlin_0-1699128720820.png

 

 

Thank you for the help! This is great! I did work on it a little more after I posted this and came up with the following:

MatchesTimecard =
    VAR selectedProjectAssignments = SELECTEDVALUE('Assignments'[Project Name])
    VAR selectedEmployeeAssignments = SELECTEDVALUE(Assignments[Employee])
   
    //Variable for counting if line item exists in Timecard
    VAR MatchExist =
    COUNTX(
        CALCULATETABLE('Hours',
        filter('Supervisor_Table', 'Supervisor_Table'[Employee] = 'Assignments'[selectedEmployeeAssignments]),
        filter('Activity', 'Activity'[Project Name] = 'Assignments'[selectedProjectAssignments])
    ), 'Hours'[Hours]) > 0

    //Variable for counting if line item exists in the original Assignments sheet
    VAR AssignmentExist =
    CALCULATE(  
        COUNTROWS('Assignments'),
        filter('Assignments', 'Assignments'[Employee] = 'Assignments'[selectedEmployeeAssignments]),
        filter('Assignments', 'Assignments'[Project Name] = 'Assignments'[selectedProjectAssignments])
    ) > 0

    Return MatchExist + AssignmentExist - 1
 
I couldn't quite get the T/F and was uing another measure to filter the table.
 
Just curious, the measure filter is needed because of the Cartesian Product of the data tables right?

Yes, without it too many combinations would show.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.