argwhichever
argwhichever, process
def nosort process argwhichever() : boolean
def process argwhichever(b: boolean) : boolean
This aggregator returns true for one selected row within each group. In its no-argument version, it arbitrarily selects one row; in the version with a boolean condition b, it returns true for one row where b is true.
b: The boolean condition to check against.
Examples
The no-argument version
table Products = with
[| as Label, as UnitPrice |]
[| "Hat", 15.00 |]
[| "Shirt", 15.00 |]
[| "Pants", 25.00 |]
Products.IsTrue = argwhichever() by Products.UnitPrice
show table "" a1c3 with
Products.Label
Products.UnitPrice
Products.IsTrue
One possible outcome is:
| Label | UnitPrice | IsTrue |
|---|---|---|
| Hat | 15.00 | true |
| Shirt | 15.00 | false |
| Pants | 25.00 | true |
Note: In groups with multiple rows, the row marked true is chosen arbitrarily.
With a boolean condition
table Products = with
[| as Label, as UnitPrice, as Eligible |]
[| "Hat", 15.00, false |]
[| "Shirt", 15.00, true |]
[| "Pants", 25.00, true |]
Products.IsTrue = argwhichever(Products.Eligible) by Products.UnitPrice
show table "" a1c3 with
Products.Label
Products.UnitPrice
Products.IsTrue
Based on the eligibility condition, the expected outcome is:
| Label | UnitPrice | Eligible | IsTrue |
|---|---|---|---|
| Hat | 15.00 | false | false |
| Shirt | 15.00 | true | true |
| Pants | 25.00 | true | true |
Note: Only rows meeting the boolean condition are eligible for selection.