Lưu ý
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử đăng nhập hoặc thay đổi thư mục.
Cần có ủy quyền mới truy nhập được vào trang này. Bạn có thể thử thay đổi thư mục.
Syntax
List.Select(list as list, selection as function) as list
About
Returns the values from the specified list that match the selection condition.
list: The list to examine.selection: The function that determines the values to select.
Example 1
Find the values in the list {1, -3, 4, 9, -2} that are greater than 0.
Usage
List.Select({1, -3, 4, 9, -2}, each _ > 0)
Output
{1, 4, 9}
Example 2
Select dates from the list that fall on Saturday or Sunday.
Usage
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
Output
{
#date(2025, 10, 25),
#date(2025, 10, 26)
}
Example 3
Display a table of active customers with purchase totals over $100.
Usage
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
Output
#table(type table[Name = text, Status = text, Purchases = number],
{
{"Alice", "Active", 150},
{"Dave", "Active", 120}
})