Merge กับ Append ต่างกันอย่างไร | Merge vs Append in Power Query explained (TH/EN)

🇹🇭 Merge กับ Append ต่างกันอย่างไรใน Power Query

สรุปจากคลิปของช่อง Lin Davoy ในซีรีส์ Basic Power BI เป็นอีกหนึ่งคำถามยอดฮิตของคนเริ่มเรียน Power BI ว่าเวลาจะเอาข้อมูลจากหลายตารางมารวมกัน ควรใช้ Merge หรือ Append ดี ในคลิปนี้ Lin อธิบายให้เห็นภาพง่ายๆ ว่าสองคำสั่งนี้ทำงานคนละแบบ แม้จะอยู่ใน Power Query Editor เหมือนกันก็ตาม ถ้าเลือกใช้ผิด ข้อมูลที่ได้อาจจะเพี้ยนไปเลยทั้งตาราง

Append คืออะไร ใช้ตอนไหน

Append Queries คือการเอาข้อมูล “ต่อแถว” กัน หรือพูดง่ายๆ คือเอาตารางที่มีโครงสร้างคอลัมน์เหมือนกัน มาเรียงต่อกันในแนวตั้ง เช่น มีไฟล์ยอดขายเดือนมกราคม กุมภาพันธ์ มีนาคม แยกไฟล์กัน แต่ละไฟล์มีคอลัมน์เหมือนกันหมด (วันที่ สินค้า ยอดขาย) พอ Append เข้าด้วยกัน ก็จะได้ตารางเดียวที่มีข้อมูลของทั้งสามเดือนเรียงต่อกันยาวลงมา จำนวนแถวจะเพิ่มขึ้น แต่จำนวนคอลัมน์จะเท่าเดิม เหมาะกับงานที่ต้องรวมข้อมูลรายเดือน รายสาขา หรือรายไฟล์ที่หน้าตาตารางเหมือนกันทุกอย่าง

Merge คืออะไร ใช้ตอนไหน

Merge Queries คือการเอาข้อมูล “ต่อคอลัมน์” กัน คล้ายกับการทำ JOIN ในภาษา SQL คือเอาสองตารางที่มีคอลัมน์ร่วมกัน (key column) เช่น รหัสสินค้า หรือรหัสลูกค้า มาจับคู่กัน แล้วดึงคอลัมน์อื่นๆ จากอีกตารางมาเติมให้ตารางหลัก ตัวอย่างเช่น มีตารางยอดขายที่มีแค่รหัสสินค้า กับมีตารางสินค้าที่บอกชื่อสินค้าและหมวดหมู่ พอ Merge สองตารางนี้เข้าด้วยกันโดยจับคู่ที่รหัสสินค้า ก็จะได้ตารางยอดขายที่มีชื่อสินค้าและหมวดหมู่เพิ่มเข้ามา จำนวนคอลัมน์จะเพิ่มขึ้น แต่จำนวนแถวมักจะเท่าเดิม (ถ้าจับคู่ได้ครบ)

ตัวอย่างการใช้งานจริงในไฟล์เดโม

ในคลิป Lin ใช้ไฟล์ตัวอย่างที่แจกไว้ให้โหลดฟรีที่ davoy.tech/pbix/ ให้ลองทำตามไปพร้อมกัน จะเห็นภาพชัดว่าเวลาจับ Append ปุ่ม “จำนวนแถว” ในตารางผลลัพธ์จะพุ่งขึ้นทันที เพราะข้อมูลถูกต่อกันในแนวตั้ง ส่วนเวลาจับ Merge จะเห็นคอลัมน์ใหม่โผล่ขึ้นมาทางขวาแทน เป็นวิธีเช็กเร็วๆ ว่าตัวเองทำถูกทางหรือเปล่า ถ้าคาดว่าแถวควรเพิ่มแต่คอลัมน์กลับเพิ่มแทน แปลว่าเลือกคำสั่งผิดแน่นอน

ตารางเปรียบเทียบ Merge vs Append

หัวข้อAppend QueriesMerge Queries
ทำงานแบบต่อแถว (เหมือน UNION)ต่อคอลัมน์ (เหมือน JOIN)
ต้องมีอะไรร่วมกันชื่อคอลัมน์เหมือนกันคอลัมน์ที่ใช้จับคู่ (key)
ผลลัพธ์จำนวนแถวเพิ่มขึ้นจำนวนคอลัมน์เพิ่มขึ้น
ใช้เมื่อไหร่รวมข้อมูลหลายไฟล์/หลายเดือนที่โครงสร้างเหมือนกันเติมข้อมูลจากอีกตารางโดยอิงรหัสอ้างอิง

สรุป: เลือกใช้อันไหนดี

ถ้าจะสรุปสั้นๆ ให้จำง่ายๆ ว่า Append คือ “เพิ่มแถว” ใช้เวลาข้อมูลหน้าตาเหมือนกันแต่มาจากคนละไฟล์ ส่วน Merge คือ “เพิ่มคอลัมน์” ใช้เวลาต้องการดึงข้อมูลจากอีกตารางมาต่อยอด เป็นพื้นฐานที่คนทำ Power BI ทุกคนต้องเข้าใจให้แม่น เพราะแทบทุกโปรเจกต์จริงจะต้องใช้ทั้งสองคำสั่งนี้สลับกันไปมา ใครที่ยังงงอยู่ ลองโหลดไฟล์ตัวอย่างมาฝึกทำตามคลิปดูจะเข้าใจเร็วขึ้นมาก


🇬🇧 Merge vs Append in Power Query, what is the difference

This article is summarized from the Lin Davoy channel, part of her Basic Power BI series. One of the most common questions for people starting out with Power BI is whether to use Merge or Append when combining data from multiple tables. In this video Lin breaks it down in a simple, visual way, showing that even though both commands live inside the same Power Query Editor, they do very different jobs. Pick the wrong one and your whole table can end up looking wrong.

What Append does and when to use it

Append Queries stacks tables on top of each other, row by row. In practice, you take tables that share the exact same columns and stack them vertically. For example, you might have separate sales files for January, February and March, each with the same columns such as date, product and sales amount. Appending them gives you one long table containing all three months worth of rows. The row count grows while the column count stays the same. This is the right tool whenever you are combining monthly files, branch reports, or any set of files that share an identical structure.

What Merge does and when to use it

Merge Queries joins tables side by side, similar to a JOIN in SQL. You take two tables that share a common key column, such as a product ID or customer ID, match rows on that key, and pull additional columns from the second table into the first. For example, if you have a sales table that only contains a product ID, and a separate product table with the product name and category, merging them on product ID adds the name and category columns to your sales table. Here the column count grows while the row count usually stays the same, assuming every row finds a match.

A quick way to check you picked the right one

In the video, Lin works through the free sample file available at davoy.tech/pbix/, which is worth downloading and following along with. Watching the preview pane makes the difference obvious: after an Append, the row count jumps because data was stacked vertically, while after a Merge, new columns appear on the right instead. That is a handy sanity check whenever you are unsure, if you expected more rows but got more columns instead, you picked the wrong command.

Merge vs Append at a glance

AspectAppend QueriesMerge Queries
How it worksStacks rows (like UNION)Joins columns (like JOIN)
What tables need in commonMatching column namesA shared key column
ResultRow count increasesColumn count increases
Use it whenCombining files or months with the same structureEnriching a table using a reference table

Verdict

The simplest way to remember it: Append adds rows, use it when the data looks the same but comes from different files. Merge adds columns, use it when you need to pull in extra information from a reference table. This is core Power BI knowledge, because almost every real project ends up using both commands together at some point. If it still feels confusing, download the sample file and follow along with the video, it clicks much faster once you try it hands on.


ติดตามข่าวสาร Data & AI ได้ที่:
Facebook: https://www.facebook.com/davoytech
YouTube: https://www.youtube.com/@linlinmhee

📌 อย่าลืมกด Like, Share และ Subscribe เป็นกำลังใจให้ด้วยนะคะ!

💬 เคยสับสนระหว่าง Merge กับ Append ไหมคะ มาคอมเมนต์เล่าให้ฟังหน่อยว่าปกติงานของเพื่อนๆ ต้องใช้คำสั่งไหนบ่อยกว่ากัน

#Davoy #DavoyTech #Linlinmhee #เรียนAI #คอร์สAI #DataAndAI #PowerBI #PowerQuery #ExcelTips #BusinessIntelligence

Chat Widget - Davoy.tech