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

How to get distinct values when two tables are joined using Union?

Hi,

I Have two tables, where table A has unique values and tables B(dynamically updated) will always contain a few records from table A.  Table A

1.png

 

Table B

2.png

 

When I do UNION, I get duplicate rows. 

 

5.png

 

I have also tried using 

Union = DISTINCT(UNION(VALUES('Table 2'[Date]),VALUES('Table 1'[Date])))  But I can only pull single column with Distinct values. 
4.png
 
I need all the columns Dates, Open, High, Low etc. without duplicate rows. 
 
Can anyone help me with this? 
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous 

This is because open High, low values has some diff.

Use Summarize and take min and max of that

Try like

summarize(UNION(VALUES('Table 2'),VALUES('Table 1')),[Date],"Open",max([Open]),"Low",min([Low]),"High",max([High]))

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous 

This is because open High, low values has some diff.

Use Summarize and take min and max of that

Try like

summarize(UNION(VALUES('Table 2'),VALUES('Table 1')),[Date],"Open",max([Open]),"Low",min([Low]),"High",max([High]))

UNION in DAX is the same as UNIONALL in SQL. Wrap the whole thing inside DISTINCT()



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.

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.