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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
blackbach2728
New Member

Compare data from two different table visuals that exist from different data sources

I have two table visuals that I have created in a dashboard in two seperate pages. This data is from two different data sources that I connected to by direct query. I need a count of how many records match from Table A to Table B by comparing the 'RelaySubstationID', 'RelayCircuitID', 'ProtectionType', 'Setting', and 'Value' columns. The 'Value' column consists of alphanumeric values but I want to compare only the numeric part. In the below case, I'd expect to get a count of 4 matching records. Is there any way to do this or is it outright impossible?

Table ATable ATable BTable B

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @blackbach2728 

 

Please try this:
Here are 2 sample data:

Table A:

vzhengdxumsft_0-1726557599603.png

Table B:

vzhengdxumsft_1-1726557621025.png

Click Transform data in the Home pane to use power query.

vzhengdxumsft_2-1726557754115.png

Click Custom Column in the Add Column pane:

vzhengdxumsft_3-1726557854979.png

 

You can use this m-code to get numbers from columns:

Text.Select([Value],{"0".."9","."})

vzhengdxumsft_4-1726557903778.png

Add for both 2 tables:

vzhengdxumsft_5-1726557926866.pngvzhengdxumsft_6-1726557933972.png

Close&Apply.

Finally, add a measure:

MEASURE =
COUNTROWS (
    FILTER (
        CROSSJOIN ( 'Table A', 'Table B' ),
        'Table A'[Custom] = 'Table B'[Custom]
    )
)

The result is as follow:

vzhengdxumsft_7-1726558006148.png

 

 

Best Regards

Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @blackbach2728 

 

Please try this:
Here are 2 sample data:

Table A:

vzhengdxumsft_0-1726557599603.png

Table B:

vzhengdxumsft_1-1726557621025.png

Click Transform data in the Home pane to use power query.

vzhengdxumsft_2-1726557754115.png

Click Custom Column in the Add Column pane:

vzhengdxumsft_3-1726557854979.png

 

You can use this m-code to get numbers from columns:

Text.Select([Value],{"0".."9","."})

vzhengdxumsft_4-1726557903778.png

Add for both 2 tables:

vzhengdxumsft_5-1726557926866.pngvzhengdxumsft_6-1726557933972.png

Close&Apply.

Finally, add a measure:

MEASURE =
COUNTROWS (
    FILTER (
        CROSSJOIN ( 'Table A', 'Table B' ),
        'Table A'[Custom] = 'Table B'[Custom]
    )
)

The result is as follow:

vzhengdxumsft_7-1726558006148.png

 

 

Best Regards

Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

parry2k
Super User
Super User

@blackbach2728 it is possible but before you get there you need to create dimensions table of all the common column that you want to compare against. Each dimension table will link to each data table and then you can compare the value column from both the tables. 

 

This is just an idea, you can tweak the solution as it fits for you.

 

To compare only number value from value  column you can do something like this:

Compare Number Values = 
VAR __ValueTableA = IFERROR ( VALUE ( SELECTEDVALUE ( 'TableA'[Value] ) ), BLANK () )
VAR __ValueTableB = IFERROR ( VALUE ( SELECTEDVALUE ( 'TableB'[Value] ) ), BLANK () )
RETURN
SWITCH ( 
   TRUE (),
   __ValueTableA == BLANK () && __ValueTableB == BLANK (), "Non number value both A and B",
   __ValueTableA == BLANK (), "Non number value table A",
   __ValueTableB == BLANK (), "Non number value table B",
   __ValueTableA <> __ValueTableB, "Mistmatched numbers",
  "Value Matched"
)

 

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! โค


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos ๐Ÿ™‚
Feel free to email me with any of your BI needs.

danextian
Super User
Super User

Hi @blackbach2728 

 

You can do an intersect between the two columns from tables A and B

COUNTROWS ( INTERSECT ( VALUES ( table1[value] ), VALUES ( table2[value] ) ) )

But both columns must contain numbers only. While that can be done in Power Query, that will most likely break query folding as welll, breaking direct query.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and Iโ€™ll forget; show me and I may remember; involve me and Iโ€™ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors