Catatan
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba masuk atau mengubah direktori.
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba mengubah direktori.
Sintaksis
List.Select(list as list, selection as function) as list
Tentang
Mengembalikan nilai dari daftar yang ditentukan yang cocok dengan kondisi pilihan.
-
list: Daftar yang akan diperiksa. -
selection: Fungsi yang menentukan nilai yang akan dipilih.
Contoh 1
Temukan nilai dalam daftar {1, -3, 4, 9, -2} yang lebih besar dari 0.
Penggunaan
List.Select({1, -3, 4, 9, -2}, each _ > 0)
Keluar
{1, 4, 9}
Contoh 2
Pilih tanggal dari daftar yang jatuh pada hari Sabtu atau Minggu.
Penggunaan
let
dates = {
#date(2025, 10, 20), // Monday
#date(2025, 10, 21), // Tuesday
#date(2025, 10, 25), // Saturday
#date(2025, 10, 26), // Sunday
#date(2025, 10, 27) // Monday
},
weekendDates = List.Select(
dates,
each Date.DayOfWeek(_, Day.Monday) >= 5
)
in
weekendDates
Keluar
{
#date(2025, 10, 25),
#date(2025, 10, 26)
}
Contoh 3
Tampilkan tabel pelanggan aktif dengan total pembelian lebih dari $100.
Penggunaan
let
customers = {
[Name = "Alice", Status = "Active", Purchases = 150],
[Name = "Bob", Status = "Inactive", Purchases = 200],
[Name = "Carol", Status = "Active", Purchases = 90],
[Name = "Dave", Status = "Active", Purchases = 120]
},
highValueActiveCustomers = List.Select(
customers,
each [Status] = "Active" and [Purchases] > 100
),
resultTable = Table.FromRecords(
highValueActiveCustomers,
type table [Name = text, Status = text, Purchases = number]
)
in
resultTable
Keluar
#table(type table[Name = text, Status = text, Purchases = number],
{
{"Alice", "Active", 150},
{"Dave", "Active", 120}
})