I have a summary table of TRADES filtered by Date (top table)
I need to get the CumResult from the last record of the filtered trades records (bottom table). Record 5 in this example.
The records in the TRADES table are sorted by Date then by Time
I can’t use min or max since the value can be positive or negative. And it can go from positive to negative. I just want to grab the value from the last record.
Seems easy because I can see it … but I’m not sure how to get it
I have separate date and time fields but didn’t know how to sort by 2 fields, so I combined them. It works, but isn’t necessary if I can sort first by date, then by time
Caveat nevertheless: performance-wise, it’s certainly much less optimized than a sort_by with a single column. On (very) big tables, this difference could matter.
I forgot to sort in the lookup equation so that even if records were sorted in my sub table, they weren’t necessarily sorted the same way in the function.
cumResult = list(Trades.lookupRecords(Date = $Date, sort_by="DateTime"))
x = cumResult[-1].AdjResult if cumResult else None
return x
You should use lookupOne in that case, easier and faster. Moreover, if this is really the whole formula, the x variable and the return are useless. So you could write your formula as follows: