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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
toovishant
Helper II
Helper II

Compare two text string same field between two different tables to identify Match/No Match

Hi Team,

I am trying to compare the Room Name between two tables to Match/No Match. I am using below logic to comapre Room Name field between Table 1 and Table 2 

The below query dosen't seems to provide the desired output. I need which Room Name is same will be "Match" and if not then it will be "No Match"

 

Validate = VAR _Table1=SELECTEDVALUE(Table1[Column4]) VAR _Table2=SELECTEDVALUE(Table2[Column4]) RETURN if(_Table1=_Table2,"Match","No Match")
 
Below sample pbix link

 

Table 1                                            Table 2 

1. Site Code                                  1. Site Code

2. Floor Code                                2. Floor Code

3. Room Code                               3. Room Code

4. Room Name                              4. Room Name

5. Validate                                      5. Validate

 

toovishant_0-1726061029554.png

 

Thanks,

 

 

 

1 ACCEPTED SOLUTION

For your eference.

mickey64_3-1726071520777.png

 

mickey64_1-1726071386676.png

 

mickey64_2-1726071423749.png

 

View solution in original post

11 REPLIES 11
Selva-Salimi
Solution Sage
Solution Sage

@toovishant 

did you have any relatioship between these two tables?! from which table did you use column 1, column2, column3 in visual and why?!

To create a unique column, I need to combine Column(1+2+3) to create a relation between these two Table 1 & Table 2

mickey64
Super User
Super User

For your reference.

 

Validate = IF(MAX('Table 1'[Column4]) = MAX('Table 2'[Column4]),"Match","No Match")

@mickey64  - Thanks for the reply. If I appy the above query it gives only "Match"

toovishant_1-1726064663273.png

 

Step 0: I use these data below.

Table 1

mickey64_0-1726068140555.png

Table 2

mickey64_1-1726068162882.png

 

Step 1: I add a relationship.

mickey64_2-1726068235533.png

 

Step 2: I make a measure.

Validate = IF(MAX('Table 1'[Column4]) = MAX('Table 2'[Column4]),"Match","No Match")

 

Step 3: I make a matrix and a table.

Matrix

mickey64_3-1726068339722.png

 

Table

mickey64_4-1726068367765.png

 

 

Sorry, In this sample file column 3 has limited data, it cannot be a unique coumn, because each site may have same room will have same room code accross the floor. So to get a unique column need to add these three Column (1+2+3) (Site+Floor Code+Room Code)

For your reference.

I add a "Key_Column" to the each table and change a relationship.

 

mickey64_0-1726069679156.png

 

mickey64_1-1726069705598.png

 

mickey64_2-1726069726692.png

 

when I use larger set of data, this query is not working.

For your eference.

mickey64_3-1726071520777.png

 

mickey64_1-1726071386676.png

 

mickey64_2-1726071423749.png

 

Selva-Salimi
Solution Sage
Solution Sage

Hi @toovishant 

 

in this case it seems that lookupvalue can perform better. then you can write as follows:

 

Validate =
VAR _Table2RoomName = LOOKUPVALUE(Table2[Column4], Table2[Column4], Table1[Column4])
RETURN IF(
Table1[Column4] = _Table2RoomName,
"Match",
"No Match"
)

 

If this post helps, then I would appreciate a thumbs up and mark it as the solution to help the other members find it more quickly. 

@Selva-Salimi  - Thanks for the reply 

when i use lookupvalue it doesn't recognize Table1[column4] or vise versa. Please can you show by using the sample table and execute this query.

 

toovishant_0-1726064489879.png

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.