---
title: Table.StopFolding – หยุด Query Folding (บังคับประมวลผลใน Power Query)
url: https://www.thepexcel.com/functions/power-query/table-functions/table-stopfolding/
type: function-explainer
program: Power Query
syntax: = Table.StopFolding(table)
date: 2025-12-15
updated: 2025-12-25
scores:
  popularity: 4
  difficulty: 6
  usefulness: 5
---

# Table.StopFolding – หยุด Query Folding (บังคับประมวลผลใน Power Query)

> Table.StopFolding ป้องกันไม่ให้ขั้นตอน downstream ถูกส่งกลับไปประมวลผลที่ data source เดิม ช่วยเมื่อ

## คำอธิบาย

Table.StopFolding ป้องกันไม่ให้ขั้นตอน downstream ถูกส่งกลับไปประมวลผลที่ data source เดิม ช่วยเมื่อต้องดีบักหรือเมื่อการบังคับประมวลผลใน Power Query ให้ผลลัพธ์ที่คาดหวัง

## Syntax

```excel
= Table.StopFolding(table)
```

## Arguments

| Name | Required | Type | Default | Description |
| --- | --- | --- | --- | --- |
| table | Yes | table |  | ตารางที่ต้องการหยุด query folding จากจุดนี้เป็นต้นไป |

## เคสการใช้งาน

### บังคับให้แปลงข้อมูลในเครื่อง

เมื่อขั้นตอนบางอย่างทำให้ query folding ล้มเหลวหรือทำให้เกิดข้อจำกัดบนแหล่งข้อมูล ให้ใช้ Table.StopFolding เพื่อย้ายการประมวลผลมาอยู่ที่ Power Query

_เหมาะกับ:_ force-local-processing

## ตัวอย่าง

### 1. ตัวอย่างที่ 1: หยุด folding หลังดึงจาก SQL

```excel
let
    Source = Sql.Database("SomeSQLServer", "MyDb"),
    MyTable = Source{[Item="MyTable"]}[Data],
    MyLocalTable = Table.StopFolding(MyTable)
in
    MyLocalTable
```

**ผลลัพธ์:** `table`

ดึงตารางจาก SQL Server แล้วเรียก Table.StopFolding เพื่อให้ขั้นตอนถัดไปไม่ถูกพยายามรันเป็นคิวรีบน SQL แต่ประมวลผลใน Power Query engine แทน ข้อมูลทั้งหมดมาแล้ว แล้วทำงานกับมันที่เครื่องเรา

### 2. ตัวอย่างที่ 2: หยุด folding ก่อนกรองเงื่อนไขที่ซับซ้อน

```excel
let
    Source = Sql.Database("Server01", "Sales"),
    Orders = Source{[Item="Orders"]}[Data],
    Local = Table.StopFolding(Orders),
    Filtered = Table.SelectRows(Local, each [Amount] > 1000 and [Status] = "Completed")
in
    Filtered
```

**ผลลัพธ์:** `table ที่ถูกกรองแล้ว`

ใช้ Table.StopFolding ก่อน Table.SelectRows เมื่อเงื่อนไขการกรองซับซ้อนหรือเมื่อข้อมูลขึ้นอยู่กับลำดับการประมวลผล บางครั้งฐานข้อมูลอาจเข้าใจเงื่อนไข AND/OR ต่างจากที่เรา คิด StopFolding บังคับให้ Power Query ตัดสินใจด้วยตัวเอง

### 3. ตัวอย่างที่ 3: เปรียบเทียบกับ Table.Buffer

```excel
let
    Source = Sql.Database("Server01", "Sales"),
    Orders = Source{[Item="Orders"]}[Data],
    Stopped = Table.StopFolding(Orders),
    Buffered = Table.Buffer(Stopped)
in
    Buffered
```

**ผลลัพธ์:** `table ที่ถูก buffer และหยุด folding`

Table.StopFolding และ Table.Buffer ทำงานต่างกัน StopFolding ป้องกันการส่งคิวรีไปยังต้นทาง ส่วน Buffer บังคับให้อ่านข้อมูลทั้งหมดและเก็บไว้ในหน่วยความจำ บ่อยครั้งที่เราใช้ทั้งสองเมื่อต้องการประสิทธิภาพ (Buffer) และความสอดคล้อง (StopFolding)

### 4. ตัวอย่างที่ 4: ดีบักปัญหาตัวอักษรพิมพ์เล็ก/ใหญ่

```excel
let
    Source = Sql.Database("Server", "DB"),
    Data = Source{[Item="Customers"]}[Data],
    Local = Table.StopFolding(Data),
    Matched = Table.SelectRows(Local, each Text.Lower([Name]) = "john doe")
in
    Matched
```

**ผลลัพธ์:** `table ที่ตรงกับการแปลง text`

SQL Server อาจจัดการตัวอักษรพิมพ์เล็ก/ใหญ่ต่างจาก Power Query (Case-sensitive vs Case-insensitive) ด้วย Table.StopFolding เราแน่ใจว่า Text.Lower ทำงานตามที่ Power Query กำหนด ไม่ใช่ตามพฤติกรรมของ SQL

## หมายเหตุเพิ่มเติม

- ผมแนะนำให้ไม่ใช้ Table.StopFolding ตั้งแต่ต้นทั้งหมด ให้ Power Query พยายาม fold ก่อน ถ้าเจอปัญหา (ผลลัพธ์ผิด, timeout) ค่อย StopFolding จุดที่ปัญหาเกิด

- ส่วนตัวผมชอบใช้ Table.StopFolding เมื่อเจอ custom function ที่ฐานข้อมูลไม่เข้าใจ หรือเมื่อต้องทำ recursive operation ฐานข้อมูลไม่ handle ได้

- ถ้า query ใช้เวลานาน (อ่านข้อมูลไม่จบ) ผมลอง StopFolding ก่อนเพิ่มหรือตัด columns ที่ไม่ต้องการ บ่อยครั้งปัญหาคือ folding แปลง SELECT * ให้ฐานข้อมูลต้องตรวจสอบทั้งตาราง

- ใช้ Diagnostics.Trace เมื่อต้องการเห็นขั้นตอนไหน folding และขั้นตอนไหน execute locally ช่วยให้เข้าใจ query flow

## คำถามที่พบบ่อย

**Q: ใช้ Table.StopFolding แล้วเร็วขึ้นเสมอไหม?**

ไม่เสมอ การย้ายงานมาทำใน Power Query (แทนที่จะให้ SQL ประมวลผล) อาจช้ากว่าเดิม ผมแนะนำให้ใช้ Table.StopFolding เมื่อจำเป็นเท่านั้น เช่น ดีบักปัญหาหรือเลี่ยงข้อจำกัดของแหล่งข้อมูล ส่วนใหญ่ folding ช่วยให้เร็ว

**Q: ต่างจาก Table.Buffer อย่างไร?**

Table.StopFolding หยุดการส่งสั่งกลับไปยัง source แต่ไม่บังคับอ่านข้อมูล ส่วน Table.Buffer บังคับให้อ่านข้อมูลทั้งหมดมาเก็บในหน่วยความจำ ใช้ Table.Buffer เมื่อต้องอ่านข้อมูลหลายครั้ง ใช้ Table.StopFolding เมื่อต้องการป้องกันปัญหา folding

**Q: มีดัชนีใดบอกว่า folding ทำงานหรือไม่?**

ใน Power Query Desktop ถ้าปลายลูกศรขึ้นด้านบน (icon ของแต่ละขั้นตอน) ชี้ไปยัง source ทำให้ folding ทำงาน ผมบอกคำแนะนำ: ใช้ Applied Steps ดูแต่ละขั้นตอน แล้วถ้า dependencies เชื่อมไปยัง source บอกว่า folding กำลังทำงาน

**Q: ควรวางจุดไหนของ query?**

วาง Table.StopFolding หลังจากดึงข้อมูลแล้ว ก่อนการแปลงผลลัพธ์ที่ซับซ้อน หรือเมื่อเจออื่น ๆ ที่ไม่ folding ได้ (เช่น List.Generate) ผมลองใช้ดู ถ้า performance ไม่ผิด ถอดออก ถ้าดีขึ้นเก็บไว้

## ฟังก์ชันที่เกี่ยวข้อง

- [Sql.Database – เชื่อมต่อฐานข้อมูล SQL Server ใน Power Query](https://www.thepexcel.com/functions/power-query/accessing-data-functions/sql-database/)
- [Table.SelectRows – กรองแถวตามเงื่อนไขใน Power Query](https://www.thepexcel.com/functions/power-query/table-functions/table-selectrows/)
- [Table.Buffer – โหลดตารางเข้า Memory เพื่อความเร็ว](https://www.thepexcel.com/functions/power-query/table-functions/table-buffer/)

## แหล่งข้อมูลเพิ่มเติม

- [Microsoft Learn: Table.StopFolding](https://learn.microsoft.com/en-us/powerquery-m/table-stopfolding) _(official)_
- [Query Folding in Power Query - Microsoft Docs](https://learn.microsoft.com/en-us/power-query/power-query-folding) _(official)_
- [SQLBI - Understanding Query Folding](https://www.sqlbi.com/blog/chris/2022/08/15/understanding-query-folding-in-power-query/) _(guide)_

---

_Source: [https://www.thepexcel.com/functions/power-query/table-functions/table-stopfolding/](https://www.thepexcel.com/functions/power-query/table-functions/table-stopfolding/)_
