Thep Excel

Value.Type – หาชนิดข้อมูลของค่า

คืนค่าชนิดข้อมูล (Type) ของค่าที่กำหนด

Value.Type จะคืนค่า Type ของ Input ที่รับเข้ามา เช่น type text, type number, type table, หรือ type list มีประโยชน์ในการตรวจสอบชนิดข้อมูลก่อนทำการแปลงหรือคำนวณ

=Value.Type(value as any) as type

By ThepExcel AI Agent
3 December 2025

Syntax & Arguments

=Value.Type(value as any) as type

Argument Type Required Default Description
value any Yes ค่าที่ต้องการตรวจสอบชนิดข้อมูล

How it works

ตรวจสอบชนิดข้อมูล

เช็คว่าค่าในคอลัมน์นี้เป็นตัวเลขหรือข้อความ เพื่อเลือกวิธีการจัดการที่เหมาะสม

สร้าง Custom Function ที่ยืดหยุ่น

เขียนฟังก์ชันที่ทำงานต่างกันตามชนิดข้อมูลที่รับเข้ามา (Polymorphic Function)

Examples

ตัวอย่างที่ 1: ตรวจสอบตัวเลข

123 เป็นตัวเลข
Power Query Formula:

=Value.Type(123)

Result:

type number

ตัวอย่างที่ 2: ตรวจสอบข้อความ

"Hello" เป็นข้อความ
Power Query Formula:

=Value.Type("Hello")

Result:

type text

ตัวอย่างที่ 3: ใช้กับเงื่อนไข

ตรวจสอบค่าใน Column1 ถ้าเป็นตัวเลขให้คืนคำว่า "Number"
Power Query Formula:

=if Value.Type([Column1]) = type number then "Number" else "Other"

Result:

"Number" หรือ "Other"

FAQs

Value.Type(null) ได้อะไร?

ได้ type null ครับ

ต่างจาก Value.Is อย่างไร?

Value.Type คืนค่า Type ออกมาเลย ส่วน Value.Is คืนค่า true/false ว่าใช่นั้นไหม (เช่น Value.Is(123, type number) = true)

Resources & Related

Resources

Additional Notes

ฟังก์ชัน Value.Type ใน Power Query ใช้สำหรับตรวจสอบชนิดข้อมูล (Data Type) ของค่าที่กำหนด ว่าเป็น Text, Number, Date หรือชนิดอื่นๆ

Leave a Reply

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