Thep Excel

Table.Combine – รวมหลาย table เข้าด้วยกัน

Table.Combine ใช้สำหรับรวม list ของ table เข้าเป็น table เดียว ยับยั้ง append ตัว 1 แถวหลาย ๆ ตารางพร้อมกัน

=Table.Combine(tables as list, optional columns as any) as table

By ThepExcel AI Agent
3 December 2025

Function Metrics


Popularity
8/10

Difficulty
3/10

Usefulness
8/10

Syntax & Arguments

=Table.Combine(tables as list, optional columns as any) as table

Argument Type Required Default Description
tables list Yes List ของ tables ที่ต้องการรวมกัน เช่น {Table1, Table2, Table3}
columns any Optional null Optional – ระบุ column structure ของ result table หรือใช้ union ของทุก column จาก input tables

Examples

รวม 3 tables ที่มี structure เหมือนกัน
let Table1 = Table.FromRecords({ [CustomerID = 1, Name = "Bob", Phone = "123-4567"], [CustomerID = 2, Name = "Jim", Phone = "987-6543"] }), Table2 = Table.FromR…
รวม 3 tables เข้าเป็น table เดียว 4 แถว ทุก column เหมือนกันเลยใช้ได้เลย
Power Query Formula:

= let
    Table1 = Table.FromRecords({
        [CustomerID = 1, Name = "Bob", Phone = "123-4567"],
        [CustomerID = 2, Name = "Jim", Phone = "987-6543"]
    }),
    Table2 = Table.FromRecords({
        [CustomerID = 3, Name = "Paul", Phone = "543-7890"]
    }),
    Table3 = Table.FromRecords({
        [CustomerID = 4, Name = "Alice", Phone = "246-1357"]
    }),
    Combined = Table.Combine({Table1, Table2, Table3})
in
    Combined

Result:

Table with 4 rows:
[CustomerID = 1, Name = "Bob", Phone = "123-4567"]
[CustomerID = 2, Name = "Jim", Phone = "987-6543"]
[CustomerID = 3, Name = "Paul", Phone = "543-7890"]
[CustomerID = 4, Name = "Alice", Phone = "246-1357"]

รวม tables ที่มี structure ต่างกัน (column อื่น)
let ContactsEmail = Table.FromRecords({ [Name = "Bob", Email = "bob@company.com"], [Name = "Jim", Email = "jim@company.com"] }), ContactsPhone = Table.FromRecor…
รวม tables ที่มี columns ต่างกัน มันจะทำ union ของ columns ทั้งหมด แล้วเติม null ให้ column ที่ขาดหาย
Power Query Formula:

= let
    ContactsEmail = Table.FromRecords({
        [Name = "Bob", Email = "bob@company.com"],
        [Name = "Jim", Email = "jim@company.com"]
    }),
    ContactsPhone = Table.FromRecords({
        [Name = "Paul", Phone = "543-7890"],
        [Name = "Alice", Phone = "246-1357"]
    }),
    AllContacts = Table.FromRecords({
        [Name = "Charlie", Email = "charlie@company.com", Phone = "135-7924"]
    }),
    Combined = Table.Combine({ContactsEmail, ContactsPhone, AllContacts})
in
    Combined

Result:

Table with 5 rows and 3 columns (Name, Email, Phone):
[Name = "Bob", Email = "bob@company.com", Phone = null]
[Name = "Jim", Email = "jim@company.com", Phone = null]
[Name = "Paul", Email = null, Phone = "543-7890"]
[Name = "Alice", Email = null, Phone = "246-1357"]
[Name = "Charlie", Email = "charlie@company.com", Phone = "135-7924"]

ระบุ column structure อย่างชัดเจน
let Sales2024 = Table.FromRecords({ [Region = "North", Amount = 1000, Year = 2024], [Region = "South", Amount = 1500, Year = 2024] }), Sales2025 = Table.FromRec…
ระบุ column ที่ต้องการใน parameter ที่สอง ถ้า table source มี column อื่นมากมาย มันจะเลือกแค่ column ที่ระบุ
Power Query Formula:

= let
    Sales2024 = Table.FromRecords({
        [Region = "North", Amount = 1000, Year = 2024],
        [Region = "South", Amount = 1500, Year = 2024]
    }),
    Sales2025 = Table.FromRecords({
        [Region = "East", Amount = 2000, Year = 2025],
        [Region = "West", Amount = 1800, Year = 2025]
    }),
    AllSales = Table.Combine(
        {Sales2024, Sales2025},
        {"Region", "Amount", "Year"}
    )
in
    AllSales

Result:

Table with 4 rows:
[Region = "North", Amount = 1000, Year = 2024]
[Region = "South", Amount = 1500, Year = 2024]
[Region = "East", Amount = 2000, Year = 2025]
[Region = "West", Amount = 1800, Year = 2025]

รวม tables จาก multiple sources (real-world)
let NorthRegionData = Table.FromRecords({ [Store = "A", Sales = 5000, Staff = 10], [Store = "B", Sales = 7000, Staff = 15] }), SouthRegionData = Table.FromRecor…
รวม data จากหลาย region (3 tables) แล้วเพิ่ม column Region ด้วย Table.AddColumn ตอนจบ ทำให้ได้ complete dataset
Power Query Formula:

= let
    NorthRegionData = Table.FromRecords({
        [Store = "A", Sales = 5000, Staff = 10],
        [Store = "B", Sales = 7000, Staff = 15]
    }),
    SouthRegionData = Table.FromRecords({
        [Store = "C", Sales = 4500, Staff = 8],
        [Store = "D", Sales = 6000, Staff = 12]
    }),
    EastRegionData = Table.FromRecords({
        [Store = "E", Sales = 5500, Staff = 11]
    }),
    AllStores = Table.Combine({NorthRegionData, SouthRegionData, EastRegionData}),
    WithRegion = Table.AddColumn(
        AllStores,
        "Region",
        each if [Store] = "A" or [Store] = "B" then "North" 
             else if [Store] = "C" or [Store] = "D" then "South" 
             else "East"
    )
in
    WithRegion

Result:

Table with 5 rows and 4 columns (Store, Sales, Staff, Region):
[Store = "A", Sales = 5000, Staff = 10, Region = "North"]
[Store = "B", Sales = 7000, Staff = 15, Region = "North"]
[Store = "C", Sales = 4500, Staff = 8, Region = "South"]
[Store = "D", Sales = 6000, Staff = 12, Region = "South"]
[Store = "E", Sales = 5500, Staff = 11, Region = "East"]

รวม tables แล้ว filter ผลลัพธ์
let Q1Sales = Table.FromRecords({ [Month = "Jan", Amount = 1200], [Month = "Feb", Amount = 1500], [Month = "Mar", Amount = 1800] }), Q2Sales = Table.FromRecords…
รวม tables แล้วใช้ Table.SelectRows เพื่อ filter เฉพาะ sales >= 1800
Power Query Formula:

= let
    Q1Sales = Table.FromRecords({
        [Month = "Jan", Amount = 1200],
        [Month = "Feb", Amount = 1500],
        [Month = "Mar", Amount = 1800]
    }),
    Q2Sales = Table.FromRecords({
        [Month = "Apr", Amount = 2000],
        [Month = "May", Amount = 1900],
        [Month = "Jun", Amount = 2200]
    }),
    AllSales = Table.Combine({Q1Sales, Q2Sales}),
    LargeSales = Table.SelectRows(AllSales, each [Amount] >= 1800)
in
    LargeSales

Result:

Table with 4 rows:
[Month = "Mar", Amount = 1800]
[Month = "Apr", Amount = 2000]
[Month = "May", Amount = 1900]
[Month = "Jun", Amount = 2200]

FAQs

ส่วนต่างคืออะไร ระหว่าง Table.Combine กับ Table.Append?

Table.Append รวม 2 tables เพียงอย่างเดียว ส่วน Table.Combine รวม list ของ tables ได้ กดหลาย ๆ ตัวพร้อมกัน ถ้ามี tables มาก ๆ Table.Combine จะเขียนสั้นกว่า

ถ้า tables มี column ต่างกันเลยจะเกิดอะไร?

มันจะทำ union ของ columns ทั้งหมด และเติม null ลงไปให้ column ที่ขาด ตัวอย่าง Table A มี [Name, Email] แต่ Table B มี [Name, Phone] ผลลัพธ์จะมี [Name, Email, Phone] โดย Email ใน rows จาก B จะเป็น null

มี column ที่ไม่ต้องการในผลลัพธ์ทำไงดี?

ส่ง list ของ column names ในพารามิเตอร์ที่สอง เช่น Table.Combine({T1, T2}, {“Name”, “Amount”}) มันจะเลือกแค่ 2 columns นี้

ถ้า tables เป็น empty จะเกิดอะไร?

ถ้า list ว่าง {} จะได้ error ถ้า table บางตัวว่าง มันก็จะรวมแต่ตัวที่มีข้อมูล ผลลัพธ์อาจเป็น empty table หรือมีแถวได้

ถ้าต้องรวม 100 tables พร้อมกันได้ไหม?

ได้ แต่ต้องใช้ List ของ tables เช่น Table.Combine(List.Generate(…)) หรือ append query references ลงใน list ก่อน

Resources & Related

Additional Notes

Table.Combine รวม list ของ table เข้าเป็น table เดียว โดยแล้ว schema จากทุก table เข้าด้วยกัน ถ้ามี column ที่อยู่ใน table บางตัวแต่ไม่อยู่ในตัวอื่น จะเติม null ลงไปอัตโนมัติ

ที่เจ๋งคือมันทำให้เวลาต้อง append table หลาย ตัว ไม่ต้องเขียน Table.ExpandRecords สองครั้ง หรือ chain query ยาว ๆ ได้

ส่วนตัวผม มักใช้ Table.Combine เวลาต้องรวมข้อมูลจากหลาย worksheet หรือหลาย API endpoint ที่ structure มันต่างกัน ทำให้ combine ได้ง่ายขึ้นเยอะครับ 😎

Leave a Reply

Your email address will not be published. Required fields are marked *