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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
POSPOS
Post Partisan
Post Partisan

How to compare two tables for same column value

Hi All,

I have a requirement to compare two tables and check if the column values in one table exists in another.

 

Two tables:

1. Master Table -- This table has row level security on user name

2. Detail Table 

3. I have created a Custom table to only get the columns values from Master table based on the user logged in and pass that to the Detail table.

 

Sample pbix - Download from here

 

Master Table : 

User NameCenterLocation
G1000176000000053032519
G1000176000000153054608
G1000176010000053054614
G1000176010100053054618
G1000176010110053054619
R0000176010130053054617
R0000176010300053054612
R0000176010500053054609
R0000176010600053054620
R0000176010700053054615
R0000176010800053054616
R0000176020000053054613

 

Detail Table : 

CenterLocationSalesExpense
1030000001530546125762457624
10300000055305461739910.3239910.32
1030000009530546129895498954
10700000025305461774842.6874842.68
1300000000530546208366283662
130070200053054612155208155208
176000000053054612139836139836
176000000053054617155916.6155916.6
176000000053054618127012127012
1760000000530546205301453014
17600000015303251918252401825240
176000000153054609488706488706
17600000015305461212579961257996
176000000153054615172881172881
176000000153054616193708193708
176000000153054617398268398268
176000000153054618326342326342
17600000015305461918598791859879
1760000001530546209055090550
176010600053054615196028196028
190000000053054608638880638880
190008000053032519532061.6532061.6
190008000053054608141972141972
19000800005305460979287267928726
19000800005305461242142944214294
190008000053054615754020754020
190008000053054616446284446284
190008000053054617113322113322
19000800005305461827155642715564
19000800005305461930136463013646
190008000053054620264524264524
195000000053054609215120215120
195000000053054615352240352240
195000000053054616712994712994
195000000053054617345190.5345190.5
195000000053054618455206455206
195000000053054619598120598120

 

Custom Table I created:

 

Custom = 
SUMMARIZE('Master Table','Master Table'[User Name],'Master Table'[Location],'Master Table'[Center])

 

POSPOS_0-1734059602194.png

 

 

Now, my requirement is, after a user logs in, the Master table gets filtered to the logged in user, I now want to compare Custom Table and Detail Table i.e., if the col "Location" from custom table exists in the Detail Table. I want to create a calculated column in the "Detail Table" as Exist/NA which is further used for other calculations.

 

Eg: when user G1000 logs in, then I want to compare Location from both Detail table and Custom table -> Create a col in Detail table saying if it exists or no.

POSPOS_2-1734060558549.png

 

Can somone please suggest on how to achieve this?

 

Thank you.

 

 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

 Hi @POSPOS 

Thank you for providing Sample .Pbix file.
use below DAX Expression and create a calculated column:

Exist Status =

IF(

   ISBLANK(RELATED('Custom'[Location])),

   "NA",

   "Exists"

)

Certain records in the detail table, specifically in the center column, do not have corresponding entries in the center column of the custom table, where a one-to-many relationship has been established. In cases where no matching records are found, the result should return as "NA". .

vshamiliv_0-1734596137903.png

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

Appreciate your Kudos!! 

Thank you



View solution in original post

10 REPLIES 10
Anonymous
Not applicable

Hi @POSPOS,

We have provided the required DAX expression and attached a screenshot for your reference. Kindly review it at your earliest convenience and let us know if it meets your needs.

we would appreciate it if you could Accept it as a solution and drop a 'Kudos' so other members can find it more easily.

Best regards,

Shamili.v

Anonymous
Not applicable

Hi @POSPOS 
I hope this information is helpful. Please let me know if you have any further questions or if you'd like to discuss this further. If this answers your question, please Accept it as a solution and give it a 'Kudos' so others can find it easily.
Thank you.

Anonymous
Not applicable

Hi @POSPOS 
We haven’t heard back since our last response and wanted to check if your query has been resolved. If not, please feel free to reach out for further assistance. If it has been resolved, kindly mark the helpful reply as the solution to make it easier for others to find. A kudos would also be greatly appreciated!
Thank you.

Anonymous
Not applicable

Hi @POSPOS 
Thank you for your patience. From the steps outlined , please let us know if anything was helpful to you, so that we can convert it into a formal answer. If so, we would appreciate it if you could Accept it as a solution and drop a 'Kudos' so other members can find it more easily.
Thank you.

Anonymous
Not applicable

 Hi @POSPOS 

Thank you for providing Sample .Pbix file.
use below DAX Expression and create a calculated column:

Exist Status =

IF(

   ISBLANK(RELATED('Custom'[Location])),

   "NA",

   "Exists"

)

Certain records in the detail table, specifically in the center column, do not have corresponding entries in the center column of the custom table, where a one-to-many relationship has been established. In cases where no matching records are found, the result should return as "NA". .

vshamiliv_0-1734596137903.png

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

Appreciate your Kudos!! 

Thank you



Anonymous
Not applicable

Hi @POSPOS

Thank you for reaching out Microsoft fabric community forum.

The sample PBIX file provided is inaccessible
Please provide sample data that covers your issue or question completely, in a usable format.

Do not include sensitive information. Do not include anything that is unrelated to the issue or question.

 

How to Get Your Question Answered Quickly - Microsoft Fabric Community

How to provide sample data in the Power BI Forum - Microsoft Fabric Community

 

Thank you

 

@Anonymous  - File is available to download here

@Anonymous  - As the file was inaccessible, I have reattached the file to download.

VahidDM
Super User
Super User

Hi @POSPOS 

 

You can create a calculated column in the Detail Table using CONTAINS to check if the Detail Table’s Location exists in the filtered Custom Table:

 

Exist Status =
IF(
    CONTAINS(
        Custom, 
        Custom[Location], 
        Detail[Location]
    ),
    "Exist",
    "NA"
)

This column returns "Exist" if the Detail Table’s Location is found in the Custom Table (which is filtered by the logged-in user’s context), otherwise "NA".

 

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

Appreciate your Kudos!! 

 

LinkedIn|Twitter|Blog |YouTube 

 

@VahidDM  - Thanks for your response, Solution is not working as expected.
Result is showing as Exist even if the value is not exisiting in the custom table. 

DAX provided is not taking the filter context based on the user. It is looking at the entire data set instead.

POSPOS_0-1734064851537.png

POSPOS_1-1734064979434.png

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors