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

Compliance check of 2 tables

Hi,

 

I have 2 tables A and B without direct relation.

 Table A there are 3000 Names and 2000 names in Table B 

I would like to compare the name of 2 tables to check the compliance of these 2 tables :

- number of same names (Card view)

- number of different names (Card view)

and a list (table view) of these same and different names. 

 

Could you please advise? 

Thank you in advance.

Tg

1 ACCEPTED SOLUTION
v-rzhou-msft
Community Support
Community Support

Hi @vnqt ,

 

I suggest you to create a DimName table with all distinct names and then do calculation based on this table.

DimName = 
VAR _UNION = UNION(VALUES('Table A'[Name]),VALUES('Table B'[Name]))
RETURN
SUMMARIZE(_UNION,[Name])

My Sample is as below.

Table A:

RicoZhou_0-1669796990946.png

Table B:

RicoZhou_1-1669796999263.png

Measure:

number of same names =
CALCULATE (
    COUNT ( DimName[Name] ),
    FILTER (
        DimName,
        AND (
            DimName[Name] IN VALUES ( 'Table A'[Name] ),
            DimName[Name] IN VALUES ( 'Table B'[Name] )
        )
    )
)
number of different names = CALCULATE(COUNT(DimName[Name])) - [number of same names]
Filter Same list =
IF (
    AND (
        SELECTEDVALUE ( DimName[Name] ) IN VALUES ( 'Table A'[Name] ),
        SELECTEDVALUE ( DimName[Name] ) IN VALUES ( 'Table B'[Name] )
    ),
    1,
    0
)

Result is as below.

Add [Filter Same list] into Same Name list (visual level filter) and set it to show items when value = 1.

Add [Filter Same list] into Different Name list (visual level filter) and set it to show items when value = 2.

RicoZhou_2-1669797178344.png

 

Best Regards,
Rico Zhou

 

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

2 REPLIES 2
v-rzhou-msft
Community Support
Community Support

Hi @vnqt ,

 

I suggest you to create a DimName table with all distinct names and then do calculation based on this table.

DimName = 
VAR _UNION = UNION(VALUES('Table A'[Name]),VALUES('Table B'[Name]))
RETURN
SUMMARIZE(_UNION,[Name])

My Sample is as below.

Table A:

RicoZhou_0-1669796990946.png

Table B:

RicoZhou_1-1669796999263.png

Measure:

number of same names =
CALCULATE (
    COUNT ( DimName[Name] ),
    FILTER (
        DimName,
        AND (
            DimName[Name] IN VALUES ( 'Table A'[Name] ),
            DimName[Name] IN VALUES ( 'Table B'[Name] )
        )
    )
)
number of different names = CALCULATE(COUNT(DimName[Name])) - [number of same names]
Filter Same list =
IF (
    AND (
        SELECTEDVALUE ( DimName[Name] ) IN VALUES ( 'Table A'[Name] ),
        SELECTEDVALUE ( DimName[Name] ) IN VALUES ( 'Table B'[Name] )
    ),
    1,
    0
)

Result is as below.

Add [Filter Same list] into Same Name list (visual level filter) and set it to show items when value = 1.

Add [Filter Same list] into Different Name list (visual level filter) and set it to show items when value = 2.

RicoZhou_2-1669797178344.png

 

Best Regards,
Rico Zhou

 

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

 

 

djurecicK2
Super User
Super User

Hi @vnqt ,

 You can use the LOOKUPVALUE function to compare fields from tables that are not related.

 

https://learn.microsoft.com/en-us/dax/lookupvalue-function-dax

 

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.