List.Product คำนวณผลคูณ (คูณ) ของตัวเลขทั้งหมดในรายการ โดยจะแสดงผลลัพธ์เป็นตัวเลขหรือ null หากไม่มีค่าตัวเลขในรายการ ฟังก์ชันนี้มีประโยชน์สำหรับการคำนวณค่าทางสถิติและการวิเคราะห์ข้อมูล เช่น การคำนวณผลคูณของราคา ปริมาณ หรือสัดส่วนต่างๆ
=List.Product(numbersList as list, optional precision as nullable number) as nullable number
=List.Product(numbersList as list, optional precision as nullable number) as nullable number
| Argument | Type | Required | Default | Description |
|---|---|---|---|---|
| numbersList | list | Yes | รายการที่มีตัวเลขที่ต้องการคำนวณผลคูณ เช่น {1, 2, 3, 4, 5} | |
| precision | nullable number | Optional | null | พารามิเตอร์ความแม่นยำของการคำนวณ (ไม่จำเป็น) |
ใช้ในการคำนวณผลคูณของปริมาณสินค้าแต่ละรายการ เช่น {2, 3, 4} ให้ผลลัพธ์ 24 ซึ่งประโยชน์สำหรับการวิเคราะห์ข้อมูลการขาย
คำนวณผลคูณของสัดส่วนการเปลี่ยนแปลง เช่น {1.1, 1.05, 1.2} เพื่อหาการเปลี่ยนแปลงรวมในช่วงเวลาหลายช่วง
ใช้ในการประมวลผลข้อมูลสถิติและการวิเคราะห์ทางคณิตศาสตร์ เพื่อหาค่าผลคูณของชุดข้อมูลตัวเลข
let Numbers = {2, 3, 4, 5}, Result = List.Product(Numbers) in Resultlet
Numbers = {2, 3, 4, 5},
Result = List.Product(Numbers)
in
Result
120
let SalesData = Table.FromRecords({ [Item = "Product A", Quantity = 2, Price = 50], [Item = "Product B", Quantity = 3, Price = 100], [Item = "Product C", Quanti…let
SalesData = Table.FromRecords({
[Item = "Product A", Quantity = 2, Price = 50],
[Item = "Product B", Quantity = 3, Price = 100],
[Item = "Product C", Quantity = 4, Price = 75]
}),
Quantities = SalesData[Quantity],
Result = List.Product(Quantities)
in
Result
24
let MixedNumbers = {1, 2, null, 3, 4, null, 5}, Result = List.Product(MixedNumbers) in Resultlet
MixedNumbers = {1, 2, null, 3, 4, null, 5},
Result = List.Product(MixedNumbers)
in
Result
120
List.Sum คำนวณผลรวม (บวก) ของตัวเลขในรายการ ส่วน List.Product คำนวณผลคูณ (คูณ) ของตัวเลข ตัวอย่าง: {2, 3, 4} กับ Sum ได้ 9 แต่กับ Product ได้ 24
หากรายการว่างหรือมีเฉพาะค่า null ฟังก์ชัน List.Product จะคืนค่า null ดังนั้นควรตรวจสอบว่ารายการมีข้อมูลก่อนใช้งาน
พารามิเตอร์ precision ใช้เพื่อกำหนดความแม่นยำของการคำนวณ โดยมักใช้กับตัวเลขทศนิยมที่ต้องการผลลัพธ์ที่แม่นยำขึ้น
หากรายการมีศูนย์ ผลลัพธ์จะเป็นศูนย์เสมอ สำหรับตัวเลขติดลบ ผลลัพธ์จะขึ้นอยู่กับจำนวนตัวเลขติดลบ (จำนวนคี่ = ติดลบ, จำนวนคู่ = บวก)
List.Product ใช้ได้กับตัวเลข integer, decimal, floating-point ทั้งหมด และจะเพิกเฉยค่า null ตามอัตโนมัติ
List.Product คำนวณผลคูณของตัวเลขทั้งหมดในรายการ Power Query