Forum Discussion

Henry1943's avatar
Henry1943
Frequent Visitor
9 years ago
Solved

How to combine two table into one

I want to combine the two table as below:

Table 1

Product nameversiondateQuantity1Quantity2
H12317/7/20173 
H12327/8/20171 
H1241 1 
H12517/11/201733
H12617/12/20172 
H1271 1 
H12817/15/201711

 

Table 2

Product nameversiondateQuantity1Quantity2
H12317/7/201733
H1232 11
H12417/9/201711
H1251 33
H1261 22
H12717/14/201711
H12817/15/201711

 

I want to get the table after combine as below

Product nameversiondateQuantity1Quantity2
H12317/7/201733
H12327/8/201711
H12417/9/201711
H12517/11/201733
H12617/12/201722
H12717/14/201711
H12817/15/201711

 

 

How could I get that?

 

  • Hi Henry1943,

    1. I create a unique calculated column using the formulas. And create relationship between the two tables.

    Column = Table1[Product name]&Table1[version]
    Column = Table2[Product name]&Table2[version]
    


    2. In table1, create calculated column using the formulas.

    New Date = IF(ISBLANK(Table1[date]),RELATED(Table2[date]),Table1[date])
    New Quantity2 = IF(ISBLANK(Table1[Quantity2]),RELATED(Table2[Quantity2]),Table1[Quantity2])


    3. Create a new table by clicking "New Table" under Modeling on Home page.

    Result = SELECTCOLUMNS(Table1,"Product name",Table1[Product name],"version",Table1[version],"date",Table1[New Date],"Quantity1",Table1[Quantity1],"Quantity2",Table1[New Quantity2])

    Please see the expected result.



    Please download the attached file to test.

    Best Regards,
    Angelia

1 Reply

  • v-huizhn-msft's avatar
    v-huizhn-msft
    Microsoft Employee

    Hi Henry1943,

    1. I create a unique calculated column using the formulas. And create relationship between the two tables.

    Column = Table1[Product name]&Table1[version]
    Column = Table2[Product name]&Table2[version]
    


    2. In table1, create calculated column using the formulas.

    New Date = IF(ISBLANK(Table1[date]),RELATED(Table2[date]),Table1[date])
    New Quantity2 = IF(ISBLANK(Table1[Quantity2]),RELATED(Table2[Quantity2]),Table1[Quantity2])


    3. Create a new table by clicking "New Table" under Modeling on Home page.

    Result = SELECTCOLUMNS(Table1,"Product name",Table1[Product name],"version",Table1[version],"date",Table1[New Date],"Quantity1",Table1[Quantity1],"Quantity2",Table1[New Quantity2])

    Please see the expected result.



    Please download the attached file to test.

    Best Regards,
    Angelia