Find a subset of a list
Function: Find a subset of a list
This action allows you to search through a list of items and extract only those that meet specific criteria. You can define one or more conditions (filters) based on the attributes of the items in your list. It's perfect for narrowing down large lists to find exactly what you need.
Input
- List: The collection of items you want to search through. Each item in this list is expected to be an object with various attributes (like a row in a spreadsheet or a record in a database).
- Filters: A set of conditions that each item in your list must satisfy to be included in the results. You can add multiple filters, and an item must match all of them.
- Attribute: The specific field or property within each item that you want to check (e.g., "Price", "Status", "Category").
- Operator: How you want to compare the chosen attribute's value.
- Equal: The attribute's value must be exactly the same as your specified value.
- Greater than: The attribute's value must be numerically larger than your specified value.
- Greater than or equal: The attribute's value must be numerically larger than or equal to your specified value.
- In: The attribute's value must be present within a list of values you provide.
- Less than: The attribute's value must be numerically smaller than your specified value.
- Less than or equal: The attribute's value must be numerically smaller than or equal to your specified value.
- Not equal: The attribute's value must not be the same as your specified value.
- Not in: The attribute's value must not be present within a list of values you provide.
- Contains: The attribute's text value must include your specified text (case-sensitive).
- Contains (ignore case): The attribute's text value must include your specified text (not case-sensitive).
- Starts with: The attribute's text value must begin with your specified text.
- Ends with: The attribute's text value must end with your specified text.
- Value: The specific data you want to compare against the chosen attribute. This could be text, a number, a date, or a list of values, depending on the operator and the attribute's type.
- Variable Name for Results: The name of the variable where the action will store the list of items that match all your filters.
Output
- Result: A list of values. This variable will contain only the items from your original list that successfully passed all the defined filters.
Execution Flow
Real-Life Examples
Example 1: Find all active employees in a department
Imagine you have a list of all employees and you want to find only those who are currently "Active" and belong to the "Sales" department.
- Inputs:
- List:
Employees(e.g.,[\{"name": "Alice", "status": "Active", "department": "Sales"\}, \{"name": "Bob", "status": "Inactive", "department": "Marketing"\}, \{"name": "Charlie", "status": "Active", "department": "Sales"\}, \{"name": "Diana", "status": "Active", "department": "HR"\}]) - Filters:
- Filter 1:
- Attribute:
status - Operator:
Equal - Value:
Active
- Attribute:
- Filter 2:
- Attribute:
department - Operator:
Equal - Value:
Sales
- Attribute:
- Filter 1:
- Variable Name for Results:
ActiveSalesEmployees
- List:
- Result: The
ActiveSalesEmployeesvariable will contain[\{"name": "Alice", "status": "Active", "department": "Sales"\}, \{"name": "Charlie", "status": "Active", "department": "Sales"\}].
Example 2: Identify products within a specific price range
You have a product catalog and need to find all products priced between $50 and $100 (inclusive).
- Inputs:
- List:
Products(e.g.,[\{"name": "Laptop", "price": 120\}, \{"name": "Mouse", "price": 25\}, \{"name": "Keyboard", "price": 75\}, \{"name": "Monitor", "price": 90\}, \{"name": "Webcam", "price": 50\}]) - Filters:
- Filter 1:
- Attribute:
price - Operator:
Greater than or equal - Value:
50
- Attribute:
- Filter 2:
- Attribute:
price - Operator:
Less than or equal - Value:
100
- Attribute:
- Filter 1:
- Variable Name for Results:
MidRangeProducts
- List:
- Result: The
MidRangeProductsvariable will contain[\{"name": "Keyboard", "price": 75\}, \{"name": "Monitor", "price": 90\}, \{"name": "Webcam", "price": 50\}].
Example 3: Filter customer orders by specific order IDs
You have a list of all customer orders and want to retrieve only those orders that match a predefined set of order IDs.
- Inputs:
- List:
CustomerOrders(e.g.,[\{"orderId": "ORD001", "customerId": "C101"\}, \{"orderId": "ORD005", "customerId": "C102"\}, \{"orderId": "ORD002", "customerId": "C101"\}, \{"orderId": "ORD010", "customerId": "C103"\}]) - Filters:
- Filter 1:
- Attribute:
orderId - Operator:
In - Value:
["ORD001", "ORD002", "ORD010"]
- Attribute:
- Filter 1:
- Variable Name for Results:
SelectedOrders
- List:
- Result: The
SelectedOrdersvariable will contain[\{"orderId": "ORD001", "customerId": "C101"\}, \{"orderId": "ORD002", "customerId": "C101"\}, \{"orderId": "ORD010", "customerId": "C103"\}].