Hello, I ran into a problem with fetching data in lookupRecords like Table.lookupRecords(id=$id,Data=1,Data=2).
Required select data for formula MAX(Table.lookupRecords(id=$id,Data=1,Data=2).Number)
I also try Table.lookupRecords(id=$id,Data<3)
but get error.
I ask for help, how can I select data by more than one condition of one column?
Do you mean finding records where either id
equals $id
, or Data
equals 1
, or Data
equals 2
? The presence of id
confuses me – it’s a built-in unique identifier for a record and I’ve never seen a reason to look up by it. Maybe you could explain that part more?
For the question of how to find records with either of two values of Data
, it makes sense, so let me answer that. Essentially, just do two lookups and combine the results. If the results could have duplicates, then you can use set
to keep the unique values.
For example:
records = set(Table.lookupRecords(Data=1)) | set(Table.lookupRecords(Data=2))
MAX(r.Number for r in records)
(The |
operator produces the union of two sets.)
To look up by a condition (like Data<3
), there isn’t a way to use lookupRecords
this way. What you could do is create a column with formula for the condition, e.g. IsSmall
with a formula $Data < 3
; then you could look up values where IsSmall
is True
with Table.lookupRecords(IsSmall=True)
.
Thank you @dmitry-grist !
My result formula:
MAX(set(Table.lookupRecords(SomeID=$id,Data=1).Number)|set(Table.lookupRecords(SomeID=$id,Data=2).Number))
How bad it is not to know python, I feel like a fool.