---
title: Table.TransformColumnTypes – เปลี่ยนชนิดข้อมูลของคอลัมน์
url: https://www.thepexcel.com/functions/power-query/table-functions/table-transformcolumntypes/
type: function-explainer
program: Power Query
syntax: "Table.TransformColumnTypes(table as table, typeTransformations as list, optional culture as nullable text) as table"
date: 2025-12-18
scores:
  popularity: 10
  difficulty: 2
  usefulness: 10
---

# Table.TransformColumnTypes – เปลี่ยนชนิดข้อมูลของคอลัมน์

> เปลี่ยนชนิดข้อมูล (Data Type) ของคอลัมน์ตามที่กำหนด พร้อม culture support

## คำอธิบาย

Table.TransformColumnTypes เปลี่ยน Data Type ของคอลัมน์ที่ระบุให้เป็นประเภทใหม่ (เช่น Text เป็น Number, Date เป็น Text) โดยใช้ built-in conversion methods เบื้องหลัง รองรับการแปลงหลายคอลัมน์พร้อมกัน และสามารถระบุ culture parameter เพื่อจัดการ locale-specific formatting สำหรับวันที่และตัวเลข เหมาะสำหรับขั้นตอนเตรียมข้อมูลก่อน Load เข้า Data Model เพื่อป้องกัน conversion errors และเพิ่มประสิทธิภาพ ใช้ร่วมกับ Table.TransformColumns, Number.From, Text.From และ Date.From เมื่อต้องการ custom transformation logic

## Syntax

```excel
Table.TransformColumnTypes(table as table, typeTransformations as list, optional culture as nullable text) as table
```

**Variant**

```excel
Table.TransformColumnTypes(table, {{"columnName", type}})
```

แปลง Type ของคอลัมน์เดียว ใช้ type constants เช่น type text, type number, Int64.Type

**Variant**

```excel
Table.TransformColumnTypes(table, {{"col1", type1}, {"col2", type2}})
```

แปลง Type หลายคอลัมน์พร้อมกัน ใช้ list ของคู่ {column, type}

**Variant**

```excel
Table.TransformColumnTypes(table, transformations, "en-US")
```

แปลง Type พร้อม Culture Code เช่น "en-US", "fr-FR", "de-DE" สำหรับ locale-specific formatting

**Variant**

```excel
Table.TransformColumnTypes(table, transformations, [Culture="en-US", MissingField=MissingField.Ignore])
```

แปลง Type พร้อม culture และ MissingField options เช่น MissingField.Ignore, MissingField.UseNull

## Arguments

| Name | Required | Type | Default | Description |
| --- | --- | --- | --- | --- |
| table | Yes | table |  | ตารางข้อมูลที่ต้องการเปลี่ยน Data Type |
| typeTransformations | Yes | list |  | รายการคู่ {"ชื่อคอลัมน์", type} เช่น {{"Amount", Int64.Type}} หรือ {{"Date", type text}, {"Value", Percentage.Type}} สำหรับหลายคอลัมน์ รองรับ type constants ได้แก่ type text, type number, Int64.Type, Currency.Type, Percentage.Type, type date, type time, type datetime, type datetimezone, type duration, type logical, type binary แต่ไม่รองรับ type list, type record, type table |
| culture | No | nullable text | null | รหัสวัฒนธรรม (Culture Code) เช่น "en-US" (สหรัฐฯ), "fr-FR" (ฝรั่งเศส), "de-DE" (เยอรมัน), "th-TH" (ไทย) ใช้สำหรับ locale-specific formatting ของวันที่และตัวเลข หรือระบุเป็น record [Culture="en-US", MissingField=MissingField.Ignore] เพื่อจัดการคอลัมน์ที่ไม่มีในตาราง (MissingField.UseNull ใส่ null, MissingField.Ignore ข้ามคอลัมน์, default คือ Error) |

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

### แปลง Text เป็น Number สำหรับคำนวณ

เมื่อ import ข้อมูลจาก CSV หรือ Text file ตัวเลขมักจะเป็น Text ("100", "200") ต้องแปลงเป็น Number (100, 200) ก่อนใช้ในการคำนวณหรือ aggregation เช่น SUM, AVERAGE เพื่อให้ Power Query สามารถประมวลผลตัวเลขได้ถูกต้อง

_เหมาะกับ:_ data-transformation

### Format วันที่ตามภูมิภาค (Locale-specific)

แปลง Date เป็น Text พร้อมระบุ Culture Code เพื่อ export ข้อมูลในรูปแบบที่ตรงตามภูมิภาค เช่น "en-US" ให้ MM/DD/YYYY (03/24/2024), "fr-FR" ให้ DD/MM/YYYY (24/03/2024), "de-DE" ให้ DD.MM.YYYY (24.03.2024) สำหรับการสร้างรายงานสำหรับ users ในภูมิภาคต่างๆ

_เหมาะกับ:_ regional-formatting

### เตรียมข้อมูลก่อน Load เข้า Data Model

กำหนด Data Type ที่ถูกต้องก่อน Load เข้า Data Model เพื่อป้องกัน conversion errors, ลดขนาดไฟล์ (เช่น Int64 เล็กกว่า Text), และเพิ่มประสิทธิภาพการ query โดยการแปลง type ที่ Power Query step แทนที่จะให้ data engine แปลงภายหลัง

_เหมาะกับ:_ data-preparation

### แปลงหลายคอลัมน์พร้อมกัน (Bulk Conversion)

แปลง Data Type ของหลายคอลัมน์ในคำสั่งเดียว เช่น แปลง OrderDate, ShipDate, DueDate เป็น type date พร้อมกัน หรือแปลง Amount, Tax, Total เป็น Currency.Type ทำให้ code กระชับและลด query steps

_เหมาะกับ:_ bulk-transformation

### จัดการคอลัมน์ที่ไม่มีด้วย MissingField options

เมื่อใช้ query เดียวกับ data sources หลายตัวที่มี schema แตกต่างกัน (เช่น บาง source ไม่มีคอลัมน์ Discount) ใช้ MissingField.Ignore เพื่อข้ามคอลัมน์ที่ไม่มีแทนที่จะเกิด error ทำให้ query ยืดหยุ่นและใช้ซ้ำได้

_เหมาะกับ:_ error-handling

## ตัวอย่าง

### 1. ตัวอย่างที่ 1: Foundation - แปลง Text เป็น Number

```excel
let
    Source = Table.FromRecords({
        [ID = 1, Amount = "100"],
        [ID = 2, Amount = "200"],
        [ID = 3, Amount = "350"]
    }),
    ChangedType = Table.TransformColumnTypes(
        Source,
        {{"Amount", Int64.Type}}
    )
in
    ChangedType
```

**ผลลัพธ์:** `Table: Amount column เป็น Number (100, 200, 350) แทน Text ("100", "200", "350")`

ตัวอย่างนี้แสดงการแปลงคอลัมน์ Amount จากข้อความ (Text) ที่เป็น "100", "200" ให้เป็นตัวเลข (Number) ที่เป็น 100, 200 โดยใช้ Int64.Type สำหรับจำนวนเต็ม
.
หลังจากการแปลงแล้ว คอลัมน์ Amount จะสามารถนำไปคำนวณได้ เช่น ใช้ List.Sum เพื่อรวมค่า ฟังก์ชันจะใช้ Number.From เบื้องหลังเพื่อแปลงค่าในแต่ละแถว (row) อัตโนมัติครับ
.
การแปลงนี้เป็นพื้นฐานที่สำคัญมากเมื่อนำเข้าข้อมูลจากไฟล์ที่ตัวเลขถูกเก็บเป็นข้อความ 💡

### 2. ตัวอย่างที่ 2: Practical - แปลงหลายคอลัมน์พร้อมกัน

```excel
let
    Source = Table.FromRecords({
        [Name = "Product A", Price = "199.50", Quantity = "10", InStock = "true"],
        [Name = "Product B", Price = "299.00", Quantity = "5", InStock = "false"]
    }),
    ChangedType = Table.TransformColumnTypes(
        Source,
        {
            {"Price", type number},
            {"Quantity", Int64.Type},
            {"InStock", type logical}
        }
    )
in
    ChangedType
```

**ผลลัพธ์:** `Table: Price เป็น Decimal (199.5, 299), Quantity เป็น Int64 (10, 5), InStock เป็น Logical (true, false)`

ตัวอย่างนี้แสดงการแปลงสามคอลัมน์พร้อมกันในคำสั่งเดียว โดยคอลัมน์ Price จากข้อความเป็น type number สำหรับทศนิยม (decimal), คอลัมน์ Quantity เป็น Int64.Type สำหรับจำนวนเต็ม (integer), และคอลัมน์ InStock จากข้อความ "true" หรือ "false" เป็น type logical ที่เป็นค่าตรรกะ (true/false)
.
ที่เจ๋งคือการใช้รายการ (list) ของคู่ {{column, type}, {column, type}} ช่วยให้คุณระบุหลายการแปลง (transformations) ในคำสั่งเดียวได้อย่างกระชับและมีประสิทธิภาพครับ 😎

### 3. ตัวอย่างที่ 3: Advanced - แปลงวันที่พร้อม Culture Code (French)

```excel
let
    Source = Table.FromRecords({
        [Company = "JS-464", Country = "USA", OrderDate = #date(2024, 3, 24)],
        [Company = "LT-331", Country = "France", OrderDate = #date(2024, 10, 5)],
        [Company = "XE-100", Country = "USA", OrderDate = #date(2024, 5, 21)]
    }),
    ChangedType = Table.TransformColumnTypes(
        Source,
        {{"OrderDate", type text}},
        "fr-FR"
    )
in
    ChangedType
```

**ผลลัพธ์:** `OrderDate เป็น Text ในรูปแบบฝรั่งเศส: "24/03/2024", "05/10/2024", "21/05/2024" (DD/MM/YYYY)`

ตัวอย่างนี้แสดงการแปลงวันที่ (Date) เป็นข้อความ (Text) โดยใช้รหัสวัฒนธรรม (Culture Code) เป็น "fr-FR" สำหรับประเทศฝรั่งเศส ทำให้วันที่ออกมาเป็นรูปแบบ DD/MM/YYYY เช่น 24/03/2024 แทนที่จะเป็น MM/DD/YYYY แบบสหรัฐอเมริกา
.
การใช้พารามิเตอร์ culture มีประโยชน์มากเมื่อต้องการส่งออกข้อมูลให้ผู้ใช้ในภูมิภาคต่างๆ เช่น ยุโรป เอเชีย หรืออเมริกา
.
ส่วนตัวผมใช้บ่อยมากเวลาทำรายงานส่งให้ต่างประเทศครับ โดยพารามิเตอร์ culture จะส่งผลต่อทั้งรูปแบบวันที่และตัวเลขตามมาตรฐานของแต่ละภูมิภาค 💡

### 4. ตัวอย่างที่ 4: Advanced - แปลงหลายคอลัมน์พร้อม Culture (German)

```excel
let
    Source = Table.FromRecords({
        [Date = #date(2024, 3, 12), Customer = "134282", Discount = 0.24368],
        [Date = #date(2024, 5, 30), Customer = "44343", Discount = 0.03556]
    }),
    ChangedType = Table.TransformColumnTypes(
        Source,
        {{"Date", type text}, {"Discount", Percentage.Type}},
        "de-DE"
    )
in
    ChangedType
```

**ผลลัพธ์:** `Date: "12.03.2024", "30.05.2024" (German DD.MM.YYYY); Discount: 24.37%, 3.56%`

ตัวอย่างนี้แสดงการแปลงสองคอลัมน์พร้อมกันโดยใช้รหัสวัฒนธรรม (Culture Code) เป็น "de-DE" สำหรับประเทศเยอรมนี
.
ทำให้วันที่เป็นรูปแบบ DD.MM.YYYY เช่น 12.03.2024 ซึ่งใช้เครื่องหมายจุด (dot) แทนเครื่องหมายทับ (slash) และคอลัมน์ Discount ถูกแปลงเป็น Percentage.Type เพื่อแสดงผลเป็นเปอร์เซ็นต์ เช่น 24.37% และ 3.56%
.
ที่น่าสนใจคือพารามิเตอร์ culture จะส่งผลต่อทั้งตัวคั่นวันที่ (date separator) และรูปแบบการแสดงผลเปอร์เซ็นต์ (percentage formatting) ตามมาตรฐานของประเทศนั้นๆ ครับ 😎

### 5. ตัวอย่างที่ 5: Real-World - จัดการ Missing Columns ด้วย MissingField.Ignore

```excel
let
    Source = Table.FromRecords({
        [OrderID = 1, Amount = "100", Status = "Active"],
        [OrderID = 2, Amount = "200", Status = "Pending"]
    }),
    // ตาราง Source ไม่มีคอลัมน์ Discount แต่เราต้องการ reusable query
    ChangedType = Table.TransformColumnTypes(
        Source,
        {{"Amount", Int64.Type}, {"Discount", type number}},
        [Culture = "en-US", MissingField = MissingField.Ignore]
    )
in
    ChangedType
```

**ผลลัพธ์:** `Table: Amount เป็น Int64 (100, 200), คอลัมน์ Discount ไม่มีจึงถูกข้าม (ไม่เกิด error)`

ตัวอย่างนี้แสดงการใช้ MissingField.Ignore ภายในพารามิเตอร์ culture เพื่อข้ามคอลัมน์ที่ไม่มีในตาราง แทนที่จะเกิดข้อผิดพลาด (error) แบบปกติ
.
วิธีนี้มีประโยชน์มากเวลาคุณต้องการใช้ query เดียวกันกับแหล่งข้อมูล (data sources) หลายตัวที่มีโครงสร้าง (schema) แตกต่างกัน เช่น บางแหล่งข้อมูลมีคอลัมน์ Discount แต่บางแหล่งไม่มี
.
ส่วนตัวผมใช้เทคนิคนี้บ่อยมากครับ เพราะช่วยให้ query ยืดหยุ่นขึ้น ตัวเลือกอื่นๆ ได้แก่ MissingField.UseNull ซึ่งจะสร้างคอลัมน์ที่มีค่า null และตัวเลือกปกติ (default) ซึ่งจะแสดงข้อผิดพลาด (Error) ทันที 💡

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

💡 **Tip**: Table.TransformColumnTypes ใช้ .From methods ของแต่ละ Type เบื้องหลัง เช่น Currency.From สำหรับ Currency.Type, Number.From สำหรับ type number, Text.From สำหรับ type text
.
ซึ่งหมายความว่าการแปลง Type จะเป็นไปตามกฎของแต่ละ .From function นั้นๆ เช่น Number.From สามารถแปลง "123" เป็น 123 ได้ แต่ "abc" จะเกิด error ทันที
.
ส่วนตัวผมใช้ฟังก์ชันนี้บ่อยมากในการเตรียมข้อมูลก่อน Load เข้า Data Model เพื่อป้องกัน data quality issues และเพิ่มประสิทธิภาพการ query ครับ 😎
.
ควรใช้ร่วมกับ Table.TransformColumns เมื่อต้องการ custom transformation logic และใช้ Number.From, Text.From, Date.From โดยตรงเมื่อต้องการ error handling ด้วย try...otherwise นะครับ 💡

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

**Q: Table.TransformColumnTypes รองรับ Data Type อะไรบ้าง?**

รองรับ type พื้นฐานได้แก่ type text, type number, Int64.Type, Currency.Type, Percentage.Type, type date, type time, type datetime, type datetimezone, type duration, type logical, type binary และ type any แต่ไม่รองรับ type ที่ซับซ้อนเช่น type list, type record, type table, type function หากพยายามใช้ type เหล่านี้จะเกิด error

**Q: ถ้าคอลัมน์ที่ระบุไม่มีในตาราง จะเกิดอะไรขึ้น?**

จะเกิด error ทันที (default behavior) แต่สามารถป้องกันได้โดยระบุ culture parameter เป็น record [Culture="en-US", MissingField=MissingField.Ignore] เพื่อข้าม column ที่ไม่มี หรือใช้ MissingField.UseNull เพื่อสร้าง column ที่มีค่า null ทุก row แทน ตัวเลือกนี้มีประโยชน์เมื่อใช้ query เดียวกับ data sources หลายตัวที่มี schema แตกต่างกัน

**Q: Culture Code ส่งผลต่อการแปลง Type อย่างไร?**

Culture Code กำหนดรูปแบบ locale-specific formatting ตามภูมิภาค เช่น วันที่: "en-US" ใช้ MM/DD/YYYY (03/24/2024), "fr-FR" ใช้ DD/MM/YYYY (24/03/2024), "de-DE" ใช้ DD.MM.YYYY (24.03.2024); ตัวเลข: ทศนิยมใช้ . (dot) หรือ , (comma), thousands separator ใช้ , หรือ . ตาม culture; เปอร์เซ็นต์: การแสดงผลของ Percentage.Type culture จะส่งผลต่อการแปลง Date → Text และ Number → Text เป็นหลัก ไม่ส่งผลต่อการแปลง Text → Date/Number

**Q: ควรใช้ Culture parameter เมื่อไร?**

ใช้เมื่อต้องการ export ข้อมูลให้ users ในภูมิภาคต่างๆ (เช่น แปลง Date เป็น Text ในรูปแบบที่เหมาะกับภูมิภาค) หรือเมื่อ import ข้อมูลที่มีรูปแบบวันที่/ตัวเลขแบบเฉพาะภูมิภาค เช่น ข้อมูลจากยุโรปที่ใช้ comma (,) เป็นทศนิยมแทน dot (.) หรือเมื่อต้องการจัดการ missing columns ด้วย MissingField options สำหรับการแปลง type ทั่วไป (เช่น Text → Number) ไม่จำเป็นต้องระบุ culture

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

Table.TransformColumnTypes ใช้ type constants (เช่น type text, Int64.Type) และรองรับ culture parameter สำหรับ locale-specific formatting โดยใช้ built-in .From methods เบื้องหลัง (เช่น Number.From, Text.From) เหมาะสำหรับการแปลง type แบบ standard ส่วน Table.TransformColumns ให้ระบุ custom transformation function (เช่น each Text.Upper([Name])) ได้ยืดหยุ่นกว่า แต่ไม่มี culture support เหมาะกับ custom logic ที่ซับซ้อน โดยทั่วไปใช้ Table.TransformColumnTypes สำหรับ type conversion และ Table.TransformColumns สำหรับ value transformation

**Q: ถ้า conversion ล้มเหลว (เช่น Text "abc" ไม่สามารถแปลงเป็น Number) จะเกิดอะไรขึ้น?**

จะเกิด error ในแถวนั้นและแสดง [Expression.Error] แทนค่า โดยค่าอื่นในแถวเดียวกันยังคงอยู่ แต่คอลัมน์ที่แปลงไม่สำเร็จจะเป็น error สามารถป้องกันได้โดยใช้ try...otherwise ก่อน Table.TransformColumnTypes เช่น Table.AddColumn(Source, "AmountClean", each try Number.From([Amount]) otherwise null) แล้วค่อยแปลง type หรือใช้ Table.TransformColumns กับ custom function ที่มี error handling แทน

**Q: Table.TransformColumnTypes มีผลต่อ performance อย่างไร?**

การแปลง type ที่เหมาะสมช่วยเพิ่มประสิทธิภาพ เพราะ (1) Data type ที่ถูกต้องใช้ memory น้อยกว่า เช่น Int64 เล็กกว่า Text, (2) Query engine ทำ aggregations (SUM, AVG) กับ Number เร็วกว่า Text, (3) Type conversion ที่ Power Query step เร็วกว่าให้ data engine แปลงภายหลัง แต่ควรแปลงเฉพาะคอลัมน์ที่จำเป็น และวาง step นี้ไว้หลัง filter steps เพื่อลดจำนวน rows ที่ต้องแปลง หลีกเลี่ยงการแปลง type ซ้ำหลาย steps

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

- [Table.TransformColumns – แปลงคอลัมน์ด้วยฟังก์ชันการแปลง](https://www.thepexcel.com/functions/power-query/table-functions/table-transformcolumns/)
- table-transformcolumn
- [Table.FromRecords – สร้างตารางจากรายการ Record](https://www.thepexcel.com/functions/power-query/table-functions/table-fromrecords/)
- [Number.From – แปลงค่าเป็นตัวเลข](https://www.thepexcel.com/functions/power-query/number-functions/number-from/)
- [Text.From – แปลงค่าเป็นข้อความ](https://www.thepexcel.com/functions/power-query/text-functions/text-from/)
- [Date.From – แปลงข้อมูลต่างประเภทเป็นวันที่](https://www.thepexcel.com/functions/power-query/date-functions/date-from/)
- [Text.Upper – แปลงข้อความเป็นตัวอักษรใหญ่](https://www.thepexcel.com/functions/power-query/text-functions/text-upper/)
- [List.Sum – รวมค่าตัวเลขในรายการ](https://www.thepexcel.com/functions/power-query/list-functions/list-sum/)
- [Table.AddColumn – เพิ่มคอลัมน์ใหม่ด้วย Calculated Values](https://www.thepexcel.com/functions/power-query/table-functions/table-addcolumn/)

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

- [Microsoft Learn - Table.TransformColumnTypes Official Documentation](https://learn.microsoft.com/en-us/powerquery-m/table-transformcolumntypes) _(documentation)_
- [PowerQuery.how - Table.TransformColumnTypes Guide](https://powerquery.how/table-transformcolumntypes/) _(guide)_
- [Microsoft Learn - Power Query M Type System and Conversion](https://learn.microsoft.com/en-us/powerquery-m/type-conversion) _(documentation)_
- [Microsoft Support - Add or Change Data Types in Power Query](https://support.microsoft.com/en-us/office/add-or-change-data-types-power-query-b8618bb6-dec6-4fe6-8974-5f799856f218) _(guide)_

---

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