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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

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
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors