Thep Excel

Table.View – สร้าง View ของตาราง

สร้างหรือแก้ไขพฤติกรรมของตาราง สำหรับการพัฒนา Custom Connector และการจัดการ Query Folding

=Table.View(view as function, handlers as record) as table

By ThepExcel AI Agent
6 December 2025

Function Metrics


Popularity
3/10

Difficulty
7/10

Usefulness
4/10

Syntax & Arguments

=Table.View(view as function, handlers as record) as table

Argument Type Required Default Description
view function Yes ฟังก์ชัน View (มักปล่อยเป็น null หากไม่ต้องการ override)
handlers record Yes Record ที่ระบุ Handlers ต่างๆ (เช่น GetType, GetRows, OnTake)

How it works

Custom Connector Development

Custom Connector Development

Implementing DirectQuery

Implementing DirectQuery

Examples

Override Table Type (กำหนดประเภทข้อมูล)
let MyType = type table [ID = number, Name = text], View = Table.View(null, [ GetType = () => MyType, GetRows = () => #table(MyType, {{1, "A"}, {2, "B"}}) ]) in…
สร้างตารางเสมือนโดยกำหนด Type และข้อมูลผ่าน Handler `GetType` และ `GetRows` เพื่อให้ Power Query รู้จักโครงสร้าง
Power Query Formula:

let
    MyType = type table [ID = number, Name = text],
    View = Table.View(null, [
        GetType = () => MyType,
        GetRows = () => #table(MyType, {{1, "A"}, {2, "B"}})
    ])
in
    View

Result:

Table (ID, Name) with Defined Type

Implement Query Folding (OnTake)
let View = Table.View(null, [ GetType = () => type table [ID = number], GetRows = () => ..., OnTake = (count) => ... // Logic to push Take (Top N) to data sourc…
ตัวอย่างโครงสร้าง (Concept) การใช้ `OnTake` เพื่อรองรับการส่งคำสั่ง `Top N` ไปยัง Data Source (Query Folding)
Power Query Formula:

let
    View = Table.View(null, [
        GetType = () => type table [ID = number],
        GetRows = () => ...,
        OnTake = (count) => ... // Logic to push Take (Top N) to data source
    ])
in
    View

Result:

Table View with Folding Support

จัดการ Error Handling (OnInvoke)
let View = Table.View(null, [ GetRows = () => ..., OnInvoke = (function, args) => ... // Custom logic ]) in View
ใช้ `OnInvoke` เพื่อดักจับและจัดการการเรียกใช้ฟังก์ชันต่างๆ กับตารางนี้ ป้องกันการเกิด Error ที่ไม่คาดคิด
Power Query Formula:

let
    View = Table.View(null, [
        GetRows = () => ...,
        OnInvoke = (function, args) => ... // Custom logic
    ])
in
    View

Result:

Table View

Resources & Related

Additional Notes

ฟังก์ชัน Table.View ใช้สำหรับสร้างหรือแก้ไขพฤติกรรมของตาราง (Handlers) มักใช้ในการพัฒนา Custom Connector หรือการจัดการ Query Folding (การส่ง Query กลับไปประมวลผลที่แหล่งข้อมูล) เป็นฟังก์ชันขั้นสูงสำหรับการจัดการ Data Source

Leave a Reply

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