Last date using Max() - Not working!

I use a filter to display some dates associated with a record.

History.Filter(Content=thisRow)

This will return a list of dates as expected.

6/3/2019, 6/15/2019, 6/25/2019, 6/28/2019, 6/29/2019

Now I would like to only display latest date which is - 6/29/2019

So I modify the function to:
History.Filter(Content=thisRow).Max()

Which results in the incorrect date 6/15/2019.

Wrong argument type
Max expects parameter value to be a number, a list of numbers, a date/time value, a list of date/time values, a formatted number, a list of formatted numbers, a percentage, a list of percentages, a currency amount, a list of currency amounts, a time duration, or a list of time durations, but found History.Filter(Content=thisRow), which can match a table, or a table.

I also tried the following function:
History.Filter(Content=thisRow).Last()

Which again results in a different date - 6/3/2019

Can anyone please let me know how to display the last date?

Thank you in advance!!

Dear @Jimmy_C

:bulb:

Oldest date: 6/3/2019 Schedule.Date.min()

Latest date: 6/17/2019 Schedule.Date.Max()

Thanks for the reply Jean!

I have tried that and it indeed sets max date but for the entire column.
History.Date.Max()

I however need to use filter to only show dates associated for the row.
History.Filter(Content=thisRow)

This creates the list of dates, I just need to now only display the latest date from this filter result.

Any ideas?
(Sorry, my coding level of understanding is somewhat limited)

If you take a look at live example Articles table, Last Date column you can see the issue.

Thank you!

Hi,

I am sorry running out of time, but please have a look to this post:

Hi,

Thanks, I looked into it and looks like it does not apply to my situation :frowning:

I might not be doing a good explanation of issue so will try to explain again.

I have a table that pulls in date data from another table using a filter.

History.Filter(Content=thisRow)

Data displays in cells correctly.
For example, 6/3/2019, 6/15/2019, 6/25/2019, 6/28/2019, 6/29/2019

Now, instead of displaying all results, I just want to display the most recent. In the above example 6/29/2019.

Is there syntax I can use on this formula to get it to work?

Original Syntax
History.Filter(Content=thisRow)

I have tried the below but it shows incorrect result:
History.Filter(Content=thisRow).Max()

I have tried the below but it shows incorrect result:
History.Filter(Content=thisRow).Last()

Any help greatly appreciated.

Dear @Jimmy_C

This is the solution:

Schedule.Filter(Date).last()=thisRow

Hi Jimmy, this is something that confused me as well when I first ran into it. Think about what this formula is doing…

You’re taking the history table as a whole and filtering it down. The filter works because it acts on the column you’ve specified as the display column but the result of the filter is a set of entire rows (represented by the display column), not a set of dates. It looks like a set of dates but it’s actually a set of row references (You can see where this is going…)

If you then apply the max() function to it you’re finding the highest row, not the latest date. It’s probably ordering on RowID or something, which is obviously not what you want.

Thankfully, the solution is dead simple: just specify the date column before the max function. So, change the formula from:

History.Filter(Content=thisRow).Max()
…to…
History.Filter(Content=thisRow).Date.Max()

It then works. :slight_smile:

3 Likes

I’m not at the computer right now, but I think I understand the problem. When you apply .Max() to a set of rows, it selects the max one NOT by filter condition (Max doesn’t know about filter condition at all) but perhaps by the display column (one with the bookmark icon).

You should try replace .Max() with .Sort(Date).Last() to get the row with max date. Or just .Date.Max() to only get the max date value, yeah

Thanks Paul. That did the trick :wink:

Hi @Paul_Danyliuk I’m struggling with something simular

I need to select a row from a table that is the latest date before a date in current table.
from that row I need a different value (jaarkost).

[Salery lines].filter([salery date]<= EndOfMonth(Date(year,2,1),0)).cost.last()

problem with this formula is I get the last row, not necessary the latest date if they are not sorted.
I tried to use sort, but then I can’t get the cost value

any suggestions?
I would love to keep it in one column, and not create an extra column for the date and use that as a reference. (since I need this in 12 columns) But if needed, that will be my way to go.

Doesn’t the .Sort([salery date]).cost.Last() do the trick?

First you filter, then you sort so that the last row is the one with the highest date value, then select the last cost.

when I try
.Sort([salery date]).cost.Last()
I get an error (tried a lot of variations)

but when I changed it to
.Sort(true,[salery date]).cost.Last()
It works

thanks for putting me in the right direction