Forum Discussion

newgirl's avatar
newgirl
Icon for Post Patron rankPost Patron
5 years ago
Solved

Appending Selected Columns from Different Tables

Hi, guys!

 

My situation is I have 3 different transaction tables with different info provided but each table has some common columns that I would like to combine to create a new table.

 

For example I have these basic sample sets:

Table 1

Date1Name1Client Code1Type1
1/1/2020NewGirl5000123Retailer

 

Table 2

Name2Date2ColorClient Code2
NewBoy1/1/2020Blue5000124

 

 

Table 3

AmountDate3Name3Client Code3
50001/1/2020NewKid5000125

 

and this is my expected output:

New Table

Client CodeName
5000123NewGirl
5000124NewBoy
5000125NewKid

 

 

I was hoping to create a new table using DAX.

  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi  newgirl ,

    Here are the steps you can follow:

    1. Create calculated column.

    New Table =
    UNION(
        SELECTCOLUMNS('Table 1',"Client Code",[Client Code1],"name",[Name1]),
        SELECTCOLUMNS('Table 2',"Client Code",[Client Code2],"name",[Name2]),
        SELECTCOLUMNS('Table 3',"Client Code",[Client Code3],"name",[Name3]))

    2. Result

    You can downloaded PBIX file from here.

     

    Best Regards,

    Liu Yang

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

3 Replies