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 |
---|---|
16 | |
10 | |
9 | |
8 | |
3 |