Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

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

 

Table B

 

When I do UNION, I get duplicate rows. 

 

 

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. 
 
I need all the columns Dates, Open, High, Low etc. without duplicate rows. 
 
Can anyone help me with this? 
  • 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]))

2 Replies

  • 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]))

    • MattAllington's avatar
      MattAllington
      Icon for Community Champion rankCommunity Champion

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