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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
YerlaSDU
Helper I
Helper I

Get sum of same items in 2 columns

Hi folks,

 

Please help!

I have a 2 columns from 2 different tables. 

1st column have  55 unique items, 2nd column 106

How can I get the sum of unique items in both columns in comparison 

YerlaSDU_0-1666786198700.png

 

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

Hi , @Thennarasu_R 

You can use this dax :

Measure = var _table1 = VALUES( 'Table1'[Column1] )
var _table2 =VALUES(Table2[Column1])
var _intersect_count =COUNTROWS( INTERSECT(_table1 , _table2))
return
COUNTROWS( _table1) +COUNTROWS(_table2 )- 2* _intersect_count

This is my test result:

vyueyunzhmsft_0-1666837683455.png

Best Regards,

Aniya Zhang

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

16 REPLIES 16
Ashish_Mathur
Super User
Super User

Hi,

Does this measure work?

=countrows(generate(values(Table1[column1]),values(Table2[column2])))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

@Ashish_Mathur 

not working also 😞

Share the download link of your PBI file and show the expected result clearly.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

@Ashish_Mathur 

There are link to the pbix

 I want to create new column "Mapped SubClass" with "SubClass from MDS", if there is no, then with "SubClass from MDS by name"

YerlaSDU_0-1667284527529.png

 

 

The answer should be 233.  This measure works

Measure = COUNTROWS(filter(SUMMARIZE('DWH DimEquipmentSERIP','DWH DimEquipmentSERIP'[EquipmentSubClass],'DWH DimEquipmentSERIP'[EquipmentSubClassName]),[EquipmentSubClass]<>BLANK()&&'DWH DimEquipmentSERIP'[EquipmentSubClassName]<>BLANK()))

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi , @YerlaSDU 

For my first resolution, you just need to update the "return":

Measure = var _table1 = VALUES( 'Table1'[Column1] )
var _table2 =VALUES(Table2[Column1])
var _intersect_count =COUNTROWS( INTERSECT(_table1 , _table2))
return
_intersect_count

Then you can get the unique count,like this:

vyueyunzhmsft_0-1667285564515.png

Best Regards,

Aniya Zhang

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

 

 

Yes, it shows matched items with SubClassCodes. How can I also compare unmatched SubClassCode items  with SubClassName column? 

v-yueyunzh-msft
Community Support
Community Support

Hi , @Thennarasu_R 

You can use this dax :

Measure = var _table1 = VALUES( 'Table1'[Column1] )
var _table2 =VALUES(Table2[Column1])
var _intersect_count =COUNTROWS( INTERSECT(_table1 , _table2))
return
COUNTROWS( _table1) +COUNTROWS(_table2 )- 2* _intersect_count

This is my test result:

vyueyunzhmsft_0-1666837683455.png

Best Regards,

Aniya Zhang

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

@v-yueyunzh-msftIt doesn't show me unique items, that 36

 

YerlaSDU_0-1666844363004.png

 

Hi , @YerlaSDU 

I see you have marked this problem, please ask if your problem is solved, if not, you can provide your sample data (.pbix or table)?

 

Best Regards,

Aniya Zhang

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

Thennarasu_R
Responsive Resident
Responsive Resident

What Dax Function You has use?

Try out  Distictcount Function..

iceparrot
Advocate II
Advocate II

Hey, 
maybe the solution posted in this thread will help to solve your problem: 
https://community.powerbi.com/t5/Desktop/distinct-count-of-multiple-columns/m-p/433060 

@iceparrot it not working for columns in different tables 

YerlaSDU_0-1666787270423.png

 

Use DistinctCount Function With Sperate column


@Thennarasu_R 

Same result) Not working also(

YerlaSDU_0-1666847366702.png

 

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.