Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Merging two columns from two tabels into one column

I've got 2 columns in 2 different tabels but my data in the table are complementary.

As i show you on this screenshot.

And i want to merge them to one column, but i doesn't exacly know how to do it.

 

 

  • Hi Anonymous ,

     

    If your two tables have the same number of columns, consider using the UNION() function.

     

    My test table1:

     

    My test table2:

     

    Please try following DAX:

    Table = UNION('Table1','Table2')

     

     

    Best regards,

    Yadong Fang

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

10 Replies

  • v-yadongf-msft's avatar
    v-yadongf-msft
    Icon for Community Support rankCommunity Support

    Hi Anonymous ,

     

    If your two tables have the same number of columns, consider using the UNION() function.

     

    My test table1:

     

    My test table2:

     

    Please try following DAX:

    Table = UNION('Table1','Table2')

     

     

    Best regards,

    Yadong Fang

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

  • lukiz84's avatar
    lukiz84
    Icon for Memorable Member rankMemorable Member

    Hi,

    -In DAX: Create a new Calculated column:

    MergedColumn := IF([Col1]<>BLANK(), [Col1], [Col2])

    -In PowerQuery: Add a custom column:

    Table.AddColumn(tbl, "MergedColumn", each if [Col1] <> null then [Col1] else [Col2])

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      It's good if i have two columns in one table. But i've got two columns. Two different files. And i need to merge one column from one file, and one column from second file.

  • lukiz84's avatar
    lukiz84
    Icon for Memorable Member rankMemorable Member

    Do you load them in PowerQuery? Tell us a little more about the structure 🙂

    • Anonymous's avatar
      Anonymous
      Not applicable

       

      In K3513 i have one column called "cena" and in the K3510 i have other column called "cena".

      And in !Miary, "Tabela", i want to create new column that will merge those two column that i just mention