---
title: List.First – ดึงสมาชิกตัวแรกจาก List
url: https://www.thepexcel.com/functions/power-query/list-functions/list-first/
type: function-explainer
program: Power Query
syntax: "= List.First(list as list, optional defaultValue as any) as any"
date: 2025-12-03
updated: 2025-12-24
scores:
  popularity: 7
  difficulty: 2
  usefulness: 7
---

# List.First – ดึงสมาชิกตัวแรกจาก List

> List.First ใช้เพื่อดึงค่าสมาชิกตัวแรกจาก List หากเอา List ว่างเปล่า ให้ใช้ค่า Default ปกป้อง

## คำอธิบาย

List.First ใช้เพื่อดึงค่าสมาชิกตัวแรกจาก List หากเอา List ว่างเปล่า ให้ใช้ค่า Default ปกป้อง

## Syntax

```excel
= List.First(list as list, optional defaultValue as any) as any
```

## Arguments

| Name | Required | Type | Default | Description |
| --- | --- | --- | --- | --- |
| list | Yes | list |  | List ที่ต้องการดึงสมาชิกตัวแรก |
| defaultValue | No | any | null | ค่าที่จะคืนกลับมาหาก List ว่างเปล่า (ค่าเริ่มต้นคือ null) |

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

### ดึงข้อมูลล่าสุด

หาก List เรียงลำดับจากใหม่ไปเก่า สามารถใช้ List.First เพื่อดึงข้อมูลล่าสุดออกมา

### ป้องกัน Error จาก List ว่าง

ใช้ดึงค่าจาก List ที่อาจจะว่างเปล่าได้ โดยกำหนดค่า Default เพื่อป้องกันการเกิด Error หรือค่า null ที่ไม่ต้องการ

## ตัวอย่าง

### 1. ตัวอย่างที่ 1: ดึงค่าตัวแรกจาก List ปกติ

```excel
= List.First({1, 2, 3})
```

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

List มี 3 ตัว ฟังก์ชันคืนค่าสมาชิกตัวแรก

### 2. ตัวอย่างที่ 2: ดึงค่าจาก List ว่างเปล่า (ไม่มี Default)

```excel
= List.First({})
```

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

List ว่างและไม่ได้ระบุค่า defaultValue จึงคืนค่า null

### 3. ตัวอย่างที่ 3: ดึงค่าจาก List ว่างเปล่า (มี Default)

```excel
= List.First({}, "ไม่มีข้อมูล")
```

**ผลลัพธ์:** `"ไม่มีข้อมูล"`

List ว่างจึงคืนค่า Default ที่ระบุไว้

### 4. ตัวอย่างที่ 4: ดึงค่าแรกจาก Filtered List (Real-world)

```excel
let
    Source = {10, 20, 30, 40, 50},
    Filtered = List.Select(Source, each _ > 25),
    FirstValue = List.First(Filtered, -1)
in
    FirstValue
```

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

Filter List ให้เหลือแค่ค่า > 25 แล้วดึงค่าแรกออกมา ถ้า Filtered List ว่าง จะคืนค่า -1

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

- ใช้ List.First คู่กับ List.Select หรือ List.Filter เพื่อดึงค่าแรกจาก Filtered Result

- ใช้ defaultValue เพื่อให้ Code Safe กับ Edge Case (List ว่าง) ไม่ต้อง try-catch

- ถ้าต้องดึงค่าแรก + ตรวจสอบว่าว่างหรือไม่ ใช้ List.FirstN แล้วเช็ค List.Count แทน

- List.First ทำงานเร็ว เพราะ Power Query ไม่ต้องลูปหรือตรวจสอบ Condition ใดๆ

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

**Q: List.First ต่างจาก List.FirstN อย่างไร?**

List.First คืนค่าสมาชิก 'ตัวเดียว' (single value) ในขณะที่ List.FirstN คืนค่าเป็น 'List' ของสมาชิก N ตัวแรก เช่น List.FirstN({1,2,3}, 1) คืนค่า {1} ไม่ใช่ 1

**Q: จะเกิดอะไรถ้า List มีสมาชิกแต่เป็นค่า null?**

ฟังก์ชันคืนค่า null นั้นออกมา ไม่ใช่ defaultValue (defaultValue ใช้เฉพาะกรณี List ว่างเท่านั้น)

**Q: ใช้ List.First กับ Table ได้ไหม?**

ไม่ได้โดยตรง ต้องแปลง Table เป็น List ก่อน โดยใช้ Table.ToList() หรือเข้าถึง Column เป็น List

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

- [List.FirstN – ดึงสมาชิก N ตัวแรกจาก List](https://www.thepexcel.com/functions/power-query/list-functions/list-firstn/)
- [List.Last – คืนค่าสมาชิกตัวสุดท้ายของ List](https://www.thepexcel.com/functions/power-query/list-functions/list-last/)
- [List.Single – คืนค่าสมาชิกเดี่ยว](https://www.thepexcel.com/functions/power-query/list-functions/list-single/)
- [List.SingleOrDefault – ค่าเดียวหรือค่าเริ่มต้น](https://www.thepexcel.com/functions/power-query/list-functions/list-singleordefault/)
- [Table.First – ดึงข้อมูลแถวแรก](https://www.thepexcel.com/functions/power-query/table-functions/table-first/)

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

- [Microsoft Learn: List.First](https://learn.microsoft.com/en-us/powerquery-m/list-first) _(official)_

---

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