.First() not returning the first row in a sorted table

I have a table of events, sorted by their start time, and filtered to hide events whose end time has passed. In the table, this is working, so the first event in the table is always the next event, or the event that’s currently going on.

I’m trying to create a variable outside of the table that grabs the next upcoming meeting by simply grabbing the first row. The code in the variable is literally just [Table Name].First(). Somehow this is returning the fourth item in the table. When .First() is applied to a table, what is used as the index? Does it not respect sorting?

I have a similar piece of functionality in one of my projects. I use .min(), which isn’t dependent on the sort order of the rows.

Dear @Bon_Champion,

I hope https://coda.io/formulas#Sort will give you the right direction :bulb:

Best wishes for 2019 :stars:
//JP

2 Likes

Sort worked! Still curious why First wouldn’t return the first displayed row. The documentation could definitely be clearer in this regard.

2 Likes

.First() still doesn’t return the first row in a sorted table. Can someone from Coda explain how it’s supposed to work? Why do we need to duplicate complex sorting rules in formulas, when we’ve already got our table sorted?

Hi.
Very short contribution.

If I have to deal with getting sorted data quickly (especially the first information), honestly I often use Rank() function and refer to Rank rather than “first”

Thanks, I didn’t know about .Rank()! Still doesn’t work though…
I do Rank(thisRow, [VIEW NAME]) but the numbers it outputs are not right. The first row is ranked “2”. I must be getting something wrong?

Edit: I would upload a screenshot but I get “Sorry, an error has occurred.”

Here is a very generic use of rank with numbers ranking, but it works also with alphabetical or dates. You’ve got to compare the current value (in my example Name) to thisTable values for the same parameters.

Try this and let me know

1 Like

Thanks for helping me! I tried that (would never have guessed the formatting…) and it looked like it worked but…

I have a filter toggle in place (basically “show client projects only” on/off) and the ranking works when that filter is on but not when it’s off.

I still can’t upload images here (?!) but here are links to the screenshots:

Update: when I renamed the first task, it jumped to rank 4… even thought it’s still the first row in the table! This doesn’t make sense! :sob: If only they’d make .First() work as expected…

I even tried this

but same thing: it works when the toggle is on (reverse order, but that’s fine), and it doesn’t work when the toggle is off.

I would have never guessed this would have been so hard to make…