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
Anonymous
Not applicable

Compare two columns

I need to compare two columns from two different tables which there is no relation between them but they both are connected to a fact table.

 

Table2------Key1-------- Facttable

Facttable---Key2-------- Table1

 

The fact table has two keys; key1 and key2.

 

I want to compare Table2_columnA with Table1_columnD, if they have the same value then return 0 otherwise return -1.

I tried with related funcation but getting error.  

1 ACCEPTED SOLUTION

@Anonymous 

Try: 

Comparison measure =
SUMX (
    SUMMARIZE (
        Facttable,
        Table2[columnA],
        Table1[columnD],
        "@result", IF ( SUM ( Table2[columnA] ) = SUM ( Table1[columndD] ), 0, -1 )
    ),
    [@result]
)

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

6 REPLIES 6
Shishir22
Solution Sage
Solution Sage

Hi @Anonymous ,

 

Can you please elaborate your requirement a bit?

How is final result expected and against what it needs to be displayed?

Do you need to result in table visual?

 

Thanks!

 

Cheers,
Shishir
Anonymous
Not applicable

@Shishir22 

I try to explain more with an example:

Eagle77_3-1620644883879.png

 

I want to compare these two columns in a measure and if both has the same value measure returns 0 otherwise return -1;  Then I want to use the returned value in report as 'Based on field' for 'Conditional formating' to use color in report.

For example for rows 1,3,5,6 the returned value would be 0 and for other rows would return -1.

@Anonymous 

Try: 

Comparison measure =
SUMX (
    SUMMARIZE (
        Facttable,
        Table2[columnA],
        Table1[columnD],
        "@result", IF ( SUM ( Table2[columnA] ) = SUM ( Table1[columndD] ), 0, -1 )
    ),
    [@result]
)

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






PaulDBrown
Community Champion
Community Champion

@Anonymous 

Any chance you can provide a dummy dataset or PBIX file?





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Anonymous
Not applicable

Unfortunately I can't but I think the question is quite clear to answer 🙂

@Anonymous 

The question might seem clear to you, but we need more information. What data type are the columns you want to compare? what are the relationships between the tables? how are you hoping to display the result?...

Please read the following recommendations

How to get your question answered quickly 

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






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.