Displaying and sorting items by last activity date

tloder
New Member

For my app, which tracks walks that people have taken shelter dogs on, I want to show a list of dogs sorted by the last walk date.

I have a dog table which has columns about the dog that are dynamic, and a walks table which is dynamically created when a new walk (activity) is performed. I can see a list of walks for each animal on the detail page, I just need to get the latest entry from that list.

I have been able to show the top walk date of the table, but the same entry shows up for each dog.

I would also like to show a conditional value on the walk date i.e. If more than one day make the text yellow, two days red

Thanks in advance for your help

0 7 410
7 REPLIES 7

There is a MAX() function you can use to get the highest value in a list of values. Simply apply it to the list of Dates for each dog - which it looks like you have already. If not and you need help, just post back here.


To color the date based time passed, you would want to use a Format Rule.

tloder
New Member

Yes, it looks like I have identified the most recent walk row for each dog, (true/false) but I want to have this show up on the dog deck view automatically under their name. That is the part I canโ€™t figure out.

What does that mean?

Youโ€™ve not provided many details, so Iโ€™ll have to make assumptions.

2X_2_2a48eee862febc47f9d682713f7df7a72da39950.png

Iโ€™m going to guess the list of addresses above corresponds directly to the Walks inline table below.

2X_4_44b855ad1635c779a39bd64f168753aa6ccea65d.png

Iโ€™d guess the date is the row label, and that the list of dates in the deck view comes from the system-generated column with an App formula expression that uses REF_ROWS(), probably having a name beginning with โ€œRelatedโ€.

The order of the rows in the inline table in the details view is determined by the configuration of the table view with a name probably ending with โ€œ_Inlineโ€ in the ref position for the (data) table containing those rows.

The order of the dates in the deck view, presumably coming from the REF_ROWS() column mentioned above, is undefined: theyโ€™re in no intentional order, they just happen to be in (what appears to be) chronological order, earliest to latest. It sounds like you either want them sorted in reverse chronological order (latest to earliest), or you just want the latest.

To order the dates in the deck view in reverse chronological order, edit the current REF_ROWS() expression to wrap it with ORDERBY(). For instance, if itโ€™s currently this:

REF_ROWS("Walks", "Dog Id")

change it to something like this:

ORDERBY(REF_ROWS("Walks", "Dog Id"), [Walk Date], TRUE)

Note that Walks and Dog Id should be replaced with whatever values are already in the current REF_ROWS() expression, and Walk Date should be replaced with the name of the column in your walks table that contains the date of the walk.

tloder
New Member

Hi Steve, I thought that my sheet was identifying which date was the most recent for each dog with a maxrow formula but it was just finding the latest walk overall.

Here is my data sheet:

What I want to do is to group the โ€˜Walksโ€™ tab rows by dog โ€œNameโ€, and show only the most recent walk for that dog on a deck, table or card view.

I have been able to display dates but not specific to the dog, just all the same date.

Essentially i want it to display this 2X_2_2e6680c1108b55f35d989326b7b4e793a71f33c5.png

Hi @tloder
I think you need to use MAX as @WillowMobileSystems has suggested. I dont know what your tables and column names are but maybe create a vitual column [Max walk date] with something like
MAX(SELECT(dogtable[Walkdate],[dog]=[_THISROW].[dogname]
You can then create a deck view with Dog and max walk date.

It looks like that worked!!! Thanks so much to all for your quick help. This is going to be really helpful for the health of the animals.

Top Labels in this Space