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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
KiliMiyamoto
Frequent Visitor

Matrix Comparison DAX Code

KiliMiyamoto_3-1702337996526.png

The above capture is a simplified example of the results I want. Currently my DAX code is:

 

Measure = IF(MAX('some_dataset'[table_of_ID]) == MAX('some_dataset'[other_table_of_ID]), "Y")
 
It doens't work because of the MAX( ), which ideally I would like to just remove but can't. Does anybody know a work around? 
 
 
table_of_IDother_table_of_ID
100104
101102
102101
103103
104100
 

 

 
 

 

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

Hi @KiliMiyamoto  ,

According to your describe, here are my test process

To achieve your goal, you can follow these steps:

Here are my test data

vheqmsft_0-1702518513299.png

1.Create a calculated table  by using DAX

  Table 2 = VALUES('Table'[table_of_ID]) 

2.Create one to one relationship between two tables

vheqmsft_1-1702518548151.png

3.Create a custom column

Column = 
    VAR T = 
      SELECTEDVALUE('Table'[other_table_of_ID])
    var N = SELECTEDVALUE('Table'[table_of_ID])
    var res = IF(T = N , "Y",BLANK())
    RETURN res

4.Use table 'Table'[other_table_of_ID] as row, 'Table2'[other_table_of_ID] as column, calculated column as value.

5.Final output

vheqmsft_2-1702518563304.png

In order for you to solve the problem faster, you can refer to the following documentation

How to Get Your Question Answered Quickly - Microsoft Fabric Community

Best Regards,
Albert He

 

View solution in original post

4 REPLIES 4
v-heq-msft
Community Support
Community Support

Hi @KiliMiyamoto  ,

According to your describe, here are my test process

To achieve your goal, you can follow these steps:

Here are my test data

vheqmsft_0-1702518513299.png

1.Create a calculated table  by using DAX

  Table 2 = VALUES('Table'[table_of_ID]) 

2.Create one to one relationship between two tables

vheqmsft_1-1702518548151.png

3.Create a custom column

Column = 
    VAR T = 
      SELECTEDVALUE('Table'[other_table_of_ID])
    var N = SELECTEDVALUE('Table'[table_of_ID])
    var res = IF(T = N , "Y",BLANK())
    RETURN res

4.Use table 'Table'[other_table_of_ID] as row, 'Table2'[other_table_of_ID] as column, calculated column as value.

5.Final output

vheqmsft_2-1702518563304.png

In order for you to solve the problem faster, you can refer to the following documentation

How to Get Your Question Answered Quickly - Microsoft Fabric Community

Best Regards,
Albert He

 

Thank you very much for your response. Unfortunately I could not get your solution to work, not because it's incorrect but because my dataset would not allow me to execute your solution. I have a larger master table, from this, I created the table 2 required. However when I try to create a relationship between the two tables I get a circular dependency error. I tried resolving this by creating a table 3 which contains only the 'other table of ID' (I shouldn't have named the variable as table) but Power BI cannot create table 3 since it exceeds 1,000,000 rows. So yeah sadly I don't think there is anyway for me to get what I want. 

littlemojopuppy
Community Champion
Community Champion

Hi @KiliMiyamoto 

 

What you're looking for is something like this

 

 

IF(
	ISEMPTY(
		INTERSECT(
			VALUES(TableOfID[FieldValue])
			VALUES(OtherTableOfID[FieldValue])
		)
	),
	BLANK(),
	TRUE()
)

 

I typed this in Notepad so I doubt it's syntatically correct but should get you to where you want to be.

Thank you very much for you response. I can see what your code does and I've tried it with my dataset but it returns this:

KiliMiyamoto_0-1702343389353.png

 

Which in fact is the exact same results as my original code, which returns:

KiliMiyamoto_2-1702343540177.png

 

 

I can't share the dataset since it belongs to my company.

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.