Thep Excel

Table.RemoveRows – ลบแถวตามจำนวนและตำแหน่งที่ระบุ

Table.RemoveRows ใช้สำหรับลบแถวออกจากตาราง โดยระบุตำแหน่งเริ่มต้นและจำนวนแถวที่ต้องการลบ

=Table.RemoveRows(table as table, offset as number, optional count as nullable number) as table

By ThepExcel AI Agent
15 December 2025

Function Metrics


Popularity
5/10

Difficulty
3/10

Usefulness
5/10

Syntax & Arguments

=Table.RemoveRows(table as table, offset as number, optional count as nullable number) as table

Argument Type Required Default Description
table table Yes ตารางที่ต้องการลบแถว
offset number Yes ตำแหน่งแถวแรกที่จะลบ (เริ่มนับจาก 0)
count number Optional 1 จำนวนแถวที่ต้องการลบ (ค่าเริ่มต้นคือ 1)

How it works

ลบข้อมูลส่วนหัวหรือส่วนท้ายที่ไม่ต้องการแบบระบุตำแหน่งได้

ลบข้อมูลส่วนหัวหรือส่วนท้ายที่ไม่ต้องการแบบระบุตำแหน่งได้

ลบข้อมูลช่วงกลางของตารางที่ทราบตำแหน่งแน่นอน

ลบข้อมูลช่วงกลางของตารางที่ทราบตำแหน่งแน่นอน

จัดการตารางที่มีรูปแบบคงที่

จัดการตารางที่มีรูปแบบคงที่

Examples

ตัวอย่างที่ 1: ลบแถวแรกสุดออก 1 แถว
let Source = Table.FromRecords({[A=1], [A=2], [A=3]}), Removed = Table.RemoveRows(Source, 0, 1) in Removed
ลบแถวที่ index 0 (แถวแรก) จำนวน 1 แถว ผลลัพธ์จะเหลือแถวที่ 2 และ 3
Power Query Formula:

let
    Source = Table.FromRecords({[A=1], [A=2], [A=3]}),
    Removed = Table.RemoveRows(Source, 0, 1)
in
    Removed

Result:

Table with row 2 and 3

ตัวอย่างที่ 2: ลบแถวช่วงกลาง (ลบแถวที่ 2 และ 3)
let Source = Table.FromRecords({[A=1], [A=2], [A=3], [A=4]}), Removed = Table.RemoveRows(Source, 1, 2) in Removed
เริ่มลบที่ index 1 (คือแถวที่ 2) และลบไป 2 แถว ทำให้แถวที่ 2 และ 3 หายไป เหลือเพียงแถวที่ 1 และ 4
Power Query Formula:

let
    Source = Table.FromRecords({[A=1], [A=2], [A=3], [A=4]}),
    Removed = Table.RemoveRows(Source, 1, 2)
in
    Removed

Result:

Table with row 1 and 4

ตัวอย่างที่ 3: ลบข้อมูลส่วนท้ายโดยระบุตำแหน่ง
let Source = Table.FromRecords({[ID=1], [ID=2], [ID=3], [ID=4], [ID=5]}), // ลบ 3 แถว เริ่มจาก index 2 (คือแถวที่ 3, 4, 5) Removed = Table.RemoveRows(Source, 2,…
เริ่มลบที่ index 2 (แถวที่ 3) จำนวน 3 แถว ทำให้แถว ID 3, 4, 5 ถูกลบออก
Power Query Formula:

let
    Source = Table.FromRecords({[ID=1], [ID=2], [ID=3], [ID=4], [ID=5]}),
    // ลบ 3 แถว เริ่มจาก index 2 (คือแถวที่ 3, 4, 5)
    Removed = Table.RemoveRows(Source, 2, 3)
in
    Removed

Result:

Table with ID 1 and 2

Resources & Related

Additional Notes

Table.RemoveRows ใช้สำหรับลบแถวออกจากตาราง โดยระบุตำแหน่งเริ่มต้น (Offset) และจำนวนแถว (Count) ที่ต้องการลบ ซึ่งมีประโยชน์ในการลบข้อมูลช่วงกลางหรือส่วนที่ไม่ต้องการออกเมื่อทราบตำแหน่งที่แน่นอน

Leave a Reply

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