I am new to Appsheet and trying to create a slice with the most recent 2 dates of a field called [date]
So the table is like this:
[ticker] [date] [value]
Ticker1 2021-01-02 10
Ticker 2 2021-01-02 11
Ticker1 2021-01-03 20
Ticker2 2021-01-03 15
Ticker1 2021-01-04 100
Ticker2 2021-01-04 120
The slice should return
Ticker1 2021-01-03 20
Ticker2 2021-01-03 15
Ticker1 2021-01-04 100
Ticker2 2021-01-04 120
It sounds very simple, but I can’t seem to find the right expression to make it work.
Maybe the following slice filter expression
IN([Date], TOP(SORT(SELECT(Table Name[Date], [ticker]=[_THISROW].[ticker]),TRUE),2))
This is what I call “brute force” - and it works, because brute force always works. But it’s rarely the actual way you should actually go about it.
REF_ROW()
on the Ticker table
TOP([Related TickerTrackers], 2)
ORDERBY()
around the REF_ROW()
to make sure things are in the correct order; fyi.OrderBy(REF_ROWS(...), [Date], true)
At this point you’ll then have the top two ticker prices for each ticker; since this lives on the ticker level (the parent), it can be extremely helpful to see things there and you might explore the possibilities you find at this point.
In your slice, change your formula to something like this:
in([TickerTrackerID], split(concatenate(Tickers[Ticker_Top_Two_Trackers]), " , ")
SELECT()
on each record of your tracker table - instead of searching through the TickerTracker table (with thousands of records) it’s searching through the Ticker table (with only a few).I know this sounds like a lot of stuff to do, like… there’s a lot going on just to accomplish something that was “easily” accomplished with a formula.
User | Count |
---|---|
18 | |
10 | |
8 | |
6 | |
5 |