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
RanHo
Helper IV
Helper IV

COMPARING 2 COLUMNS AND FIND A MATCH ON ITS DATA


Good day Guys!

               I just want to ask how I can compare 2 columns to find the matching data  in same table
Here's my example: 
As you can see I have 2 columns if the data on COLUMN1 has matched on COLUMN2 then it counts. 

RanHo_0-1662606326901.png
Thanks in advance!

~Ran

 

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

You can try

Num matches =
COUNTROWS (
    INTERSECT ( VALUES ( 'Table'[Column1] ), VALUES ( 'Table'[Column2] ) )
)

View solution in original post

6 REPLIES 6
v-shex-msft
Community Support
Community Support

Hi @RanHo,

I test with a sample formula that is similar to 'johnt75' provided and it work well, did any whitespace or special character in your fact table records?

Can you please some dummy data that keep the raw data structure and paste it here in table format? It should help us clarify your scenario and test to coding formula.

How to Get Your Question Answered Quickly  

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

@v-shex-msft  Yes I already accepted it as a solution. My bad self error, but it's solved now thanks.

johnt75
Super User
Super User

You can try

Num matches =
COUNTROWS (
    INTERSECT ( VALUES ( 'Table'[Column1] ), VALUES ( 'Table'[Column2] ) )
)

@johnt75  My bad, I retry your measure and it smoothly worked. Thanks a lot.

@johnt75  I already try it but unfortunately it's not working the output was blank. But thanks for reply.

~Ran

Anonymous
Not applicable

Hi @RanHo ,

This is not the best solution but should produce the output you are looking for. Assuming you have 1 table below:

Dax_Noob_1-1662972541952.png


Step 1: Create a calculated table using " Column 2"

Table = SUMMARIZE(Sheet1,Sheet1[Column2])


Step 2: Build a relationship between the two tables 

Dax_Noob_2-1662972616367.png


Step 3: Create a new measure

Measure = 

CALCULATE(
    COUNT(Sheet1[Column1]),
    FILTER(Sheet1,Sheet1[Column1] = RELATED('Table'[Column2])
    )
)


Step 4: Visualize

Dax_Noob_3-1662972664823.png

 

BR

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.