Thep Excel

Table.FillDown – เติมค่าว่างด้วยค่าจากแถวด้านบน

Table.FillDown เติมเต็มค่า null ด้วยค่าจากแถวด้านบน (forward fill) เหมาะสำหรับข้อมูลที่มีการ merge cell หรือจัดกลุ่มข้อมูลแบบ hierarchical ทำให้ได้ตารางที่สมบูรณ์พร้อมใช้ต่อได้เลย

= Table.FillDown(table as table, columns as list) as table

By ThepExcel AI Agent
3 December 2025

Function Metrics


Popularity
8/10

Difficulty
3/10

Usefulness
8/10

Syntax & Arguments

= Table.FillDown(table as table, columns as list) as table

Argument Type Required Default Description
table table Yes ตารางข้อมูลต้นฉบับที่มีค่า null ที่ต้องการเติมเต็ม
columns list Yes List ของชื่อคอลัมน์ที่ต้องการ fill down (เช่น {“Department”, “Category”})

Examples

เติมคอลัมน์ Category เดี่ยว
let Source = #table( {"Category", "Item", "Price"}, {{"Fruit", "Apple", 10}, {null, "Banana", 5}, {null, "Orange", 8}, {"Veg", "Carrot", 3}, {null, "Corn", 4}}…
null ในคอลัมน์ Category จะเติมด้วยค่า "Fruit" จนกว่าจะเจอค่า "Veg" ที่ต่างกัน – ทำให้ข้อมูลสมบูรณ์แล้วสามารถ group หรือ analyze ได้
Power Query Formula:

= let
    Source = #table(
        {"Category", "Item", "Price"},
        {{"Fruit", "Apple", 10}, {null, "Banana", 5}, {null, "Orange", 8}, {"Veg", "Carrot", 3}, {null, "Corn", 4}}
    ),
    Filled = Table.FillDown(Source, {"Category"})
in
    Filled

Result:

Table: (Fruit, Apple, 10), (Fruit, Banana, 5), (Fruit, Orange, 8), (Veg, Carrot, 3), (Veg, Corn, 4)

เติมหลายคอลัมน์พร้อมกัน (ข้อมูล Hierarchical)
let Source = #table( {"Company", "Department", "Employee", "Salary"}, {{"TechCorp", "IT", "Alice", 50000}, {null, null, "Bob", 48000}, {null, "HR", "Carol", 450…
ระบุสองคอลัมน์ {"Company", "Department"} ทำให้ null ในทั้ง Company และ Department จะเติมด้วยค่าจากด้านบน – ข้อมูล hierarchical สมบูรณ์แล้ว สามารถ group by ได้เลย
Power Query Formula:

= let
    Source = #table(
        {"Company", "Department", "Employee", "Salary"},
        {{"TechCorp", "IT", "Alice", 50000}, {null, null, "Bob", 48000}, {null, "HR", "Carol", 45000}, {null, null, "Dave", 46000}, {"FineCorp", "Finance", "Eve", 55000}}
    ),
    Filled = Table.FillDown(Source, {"Company", "Department"})
in
    Filled

Result:

Table: (TechCorp, IT, Alice, 50000), (TechCorp, IT, Bob, 48000), (TechCorp, HR, Carol, 45000), (TechCorp, HR, Dave, 46000), (FineCorp, Finance, Eve, 55000)

แก้ข้อมูลจาก Excel ที่มี Merge Cell
let Source = #table( {"Section", "Subsection", "Item", "Qty"}, {{"OfficeSupplies", "Writing", "Pen", 100}, {null, null, "Pencil", 50}, {null, "Paper", "A4", 200…
Excel ที่มี merge cell มักจะ import มาด้วย null หลายตัว เมื่อใช้ FillDown ก็จะได้ข้อมูลที่สมบูรณ์ แล้วนำไป สร้าง pivot หรือ group ได้ตรงตัว
Power Query Formula:

= let
    Source = #table(
        {"Section", "Subsection", "Item", "Qty"},
        {{"OfficeSupplies", "Writing", "Pen", 100}, {null, null, "Pencil", 50}, {null, "Paper", "A4", 200}, {null, null, "Notebook", 30}}
    ),
    Filled = Table.FillDown(Source, {"Section", "Subsection"})
in
    Filled

Result:

Table: (OfficeSupplies, Writing, Pen, 100), (OfficeSupplies, Writing, Pencil, 50), (OfficeSupplies, Paper, A4, 200), (OfficeSupplies, Paper, Notebook, 30)

จัดการข้อมูล Sales ที่มี null ใน Date และ Region
let Source = #table( {"Date", "Region", "Product", "Sales"}, {{"2025-01-01", "Bangkok", "Laptop", 5}, {null, null, "Desktop", 3}, {null, null, "Monitor", 2}, {"…
ข้อมูล sales ที่หลายแถวใช้ Date และ Region เดียวกัน จึงเก็บเป็น null เพื่อประหยัดพื้นที่ FillDown จะช่วยเติมให้สมบูรณ์ และสามารถ pivot หรือ group by date/region ได้
Power Query Formula:

= let
    Source = #table(
        {"Date", "Region", "Product", "Sales"},
        {{"2025-01-01", "Bangkok", "Laptop", 5}, {null, null, "Desktop", 3}, {null, null, "Monitor", 2}, {"2025-01-02", "Chiang Mai", "Laptop", 4}, {null, null, "Phone", 6}}
    ),
    Filled = Table.FillDown(Source, {"Date", "Region"})
in
    Filled

Result:

Table: (2025-01-01, Bangkok, Laptop, 5), (2025-01-01, Bangkok, Desktop, 3), (2025-01-01, Bangkok, Monitor, 2), (2025-01-02, Chiang Mai, Laptop, 4), (2025-01-02, Chiang Mai, Phone, 6)

ใช้หลังจาก Import เพื่อปรับเตรียมข้อมูล
let Source = Csv.Document(File.Contents("C:\\data.csv"), null, ",", null, 1252), Headers = Table.PromoteHeaders(Source), Filled = Table.FillDown(Headers, {"Cate…
วิธีการใช้จริง: Import CSV → Promote Headers → FillDown เพื่อให้ข้อมูลสมบูรณ์ → SelectRows เพื่อกรอง – นี่คือ workflow ที่ผมใช้เกือบทุกวัน 😎
Power Query Formula:

= let
    Source = Csv.Document(File.Contents("C:\\data.csv"), null, ",", null, 1252),
    Headers = Table.PromoteHeaders(Source),
    Filled = Table.FillDown(Headers, {"Category", "SubCategory"}),
    Filtered = Table.SelectRows(Filled, each [Sales] > 1000)
in
    Filtered

Result:

Table: ข้อมูล sales > 1000 พร้อมข้อมูล Category และ SubCategory สมบูรณ์แล้ว

FAQs

ถ้าแถวแรกเป็น null จะเกิดอะไรขึ้น?

ค่า null ในแถวแรก (ที่ไม่มีค่าด้านบนให้ยืมมา) จะยังคงเป็น null นะครับ เพราะว่า FillDown จะดึงค่าจากแถวด้านบนเท่านั้น ถ้าแถวแรกมี null ไม่มีค่าด้านบนจึงไม่สามารถเติมได้ – ลองใช้ Table.ReplaceValue หรือ Table.FillUp สำหรับแถวแรก

FillDown แล้วข้อมูลเหมือนเดิม เพราะไง?

เจอบ่อยครับ 😅 ส่วนมากเพราะว่าไม่มี null เลย ถ้าคอลัมน์ไม่มี null อยู่แล้ว FillDown ก็ไม่ต้องทำอะไร ลองเช็คด้วย View ที่ทำให้เห็น null หรือใช้ Table.Profile เพื่อดูจำนวน null ในแต่ละคอลัมน์

ต่างกับ Table.FillUp ยังไง?

FillDown ดึงค่าจากแถวด้านบน (forward fill), FillUp ดึงค่าจากแถวด้านล่าง (backward fill) – เลือกให้เหมาะกับลักษณะข้อมูลของเราครับ

เกิด error ว่า 'column not found' เพราะไง?

ชื่อคอลัมน์ในลิสต์ต้องตรงกับชื่อในตาราง (case-sensitive) – เช็คสะกดให้ถูกนะครับ ถ้าคอลัมน์ไม่มี FillDown จะ error ทันที

สามารถใช้กับ dynamic columns list ได้ไหม?

ได้ครับ เช่น เก็บชื่อคอลัมน์ในตัวแปรแล้วส่งเข้า FillDown ได้เลย – เรียก List.Select หรือ Table.ColumnNames เพื่อหาคอลัมน์ที่ต้องการเติม

Resources & Related

Additional Notes

Table.FillDown(table, columns) ใช้เติมเต็มค่าว่าง (null) ในคอลัมน์ที่ระบุ ด้วยค่าจากแถวข้างบนสุด (forward fill)

ที่เจ๋งคือ ฟังก์ชันนี้ช่วยแก้ปัญหาข้อมูลที่มาจาก Excel ที่เคยมี merge cell – แค่ใส่ชื่อแผนก/หัวข้อไว้บรรทัดแรก แล้วทำให้ null ลงมา ปล่อยให้ FillDown ช่วยเติมให้ครับ ทำให้การ transform ข้อมูลเร็วขึ้นเยอะ 😎

ส่วนตัวผมใช้ Table.FillDown ก่อน Table.SelectRows เสมอ เพราะฉะนั้นข้อมูลจึงเสร็จสมบูรณ์แล้วจึงกรองข้อมูลต่อ

Leave a Reply

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