---
title: List.RemoveMatchingItems – ลบสมาชิกที่ตรงกันด้วย Comparer
url: https://www.thepexcel.com/functions/power-query/list-functions/list-removematchingitems/
type: function-explainer
program: Power Query
syntax: "List.RemoveMatchingItems(list as list, removeItems as list, optional comparer as nullable function) as list"
date: 2025-12-03
updated: 2025-12-17
scores:
  popularity: 5
  difficulty: 4
  usefulness: 5
---

# List.RemoveMatchingItems – ลบสมาชิกที่ตรงกันด้วย Comparer

> ลบสมาชิกที่ตรงกันโดยระบุวิธีการเปรียบเทียบ

## คำอธิบาย

List.RemoveMatchingItems จะคืน List ใหม่ที่ไม่มีสมาชิกที่ตรงกับสมาชิกใน removeItems List โดยใช้ Comparer ที่กำหนด เช่น Comparer.OrdinalIgnoreCase เพื่อลบรายการแบบไม่สนใจตัวพิมพ์เล็ก/ใหญ่ ซึ่งเป็นจุดเด่นที่ทำให้ฟังก์ชันนี้ยืดหยุ่นกว่า List.RemoveItems

## Syntax

```excel
List.RemoveMatchingItems(list as list, removeItems as list, optional comparer as nullable function) as list
```

## Arguments

| Name | Required | Type | Default | Description |
| --- | --- | --- | --- | --- |
| list | Yes | list |  | List หลักที่ต้องการลบสมาชิกออก |
| removeItems | Yes | list |  | List ของสมาชิกที่ต้องการลบออกจาก List หลัก |
| comparer | No | function | Comparer.Ordinal | ฟังก์ชัน Comparer สำหรับกำหนดวิธีการเปรียบเทียบ (เช่น Comparer.OrdinalIgnoreCase) |

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

### ทำความสะอาด Blacklist (Case Insensitive)

ลบรายการสินค้าที่อยู่ใน Blacklist โดยไม่สนใจตัวพิมพ์เล็ก/ใหญ่ ของรหัสสินค้า

### กรองข้อมูลที่คล้ายกัน

ใช้ Comparer แบบพิเศษ (ถ้ามี) เพื่อลบรายการที่มีลักษณะคล้ายกันออก

## ตัวอย่าง

### 1. ตัวอย่างที่ 1: ลบแบบ Case Sensitive

```excel
List.RemoveMatchingItems({"a","b","c","d","e"}, {"A","C","D"})
```

**ผลลัพธ์:** `{"a","b","c","d","e"}`

เนื่องจากเป็น Case Sensitive "a" ไม่เท่ากับ "A" จึงไม่มีอะไรถูกลบ

### 2. ตัวอย่างที่ 2: ลบแบบ Case Insensitive

```excel
List.RemoveMatchingItems({"a","b","c","d","e"}, {"A","C","D"}, Comparer.OrdinalIgnoreCase)
```

**ผลลัพธ์:** `{"b","e"}`

ใช้ Comparer.OrdinalIgnoreCase ทำให้ "a" เท่ากับ "A" จึงลบได้

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

**Q: Comparer.OrdinalIgnoreCase คืออะไร?**

เป็นฟังก์ชันที่ใช้ในการเปรียบเทียบค่าโดยไม่สนใจตัวพิมพ์เล็ก/ใหญ่ (Case Insensitive) และไม่สนใจวัฒนธรรม (Culture Invariant)

**Q: มี Comparer แบบอื่นอีกไหม?**

มีครับ เช่น Comparer.Ordinal (Case Sensitive), Comparer.FromCulture("th-TH", true) สำหรับการเปรียบเทียบตามวัฒนธรรม

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

- [List.RemoveItems – ลบสมาชิกที่กำหนดออกจาก List](https://www.thepexcel.com/functions/power-query/list-functions/list-removeitems/)
- [Comparer.OrdinalIgnoreCase – เปรียบเทียบข้อความแบบไม่สนใจตัวพิมพ์](https://www.thepexcel.com/functions/power-query/comparer-functions/comparer-ordinalignorecase/)
- [List.Distinct – ลบค่าซ้ำออกจาก List](https://www.thepexcel.com/functions/power-query/list-functions/list-distinct/)

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

- [Microsoft Learn: List.RemoveMatchingItems](https://learn.microsoft.com/en-us/powerquery-m/list-removematchingitems) _(Official Documentation)_
- [PowerQuery.how](https://powerquery.how/list-removematchingitems/) _(guide)_

---

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