Displaying and sorting items by last activity date

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

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.

2 Likes

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.

image

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

image

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.

3 Likes

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 image

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.

4 Likes

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.

3 Likes