Issues Filtering a Button

Hello,

I am having trouble properly filtering a button. I have an Interaction Log Database, that has a lookup column pointing to a DB of employee’s names. The Interaction Log Database can have multiple rows with the same employee. I have a button to schedule the next interaction with such employee, but I don’t want the button to be enabled on the employee’s old interactions. I only want it enabled on the most recent interaction with the employee.

I am using the Disable If function on the button, below is the formula…

thisRow.Date != [Interaction Log DB].Date.Filter(thisRow.Employee).Max()

For some reason, it’s skipping the part of filtering by name, and is instead searching the entire database for the most recent interaction. What I am wanting is for the button to also be enabled for Name 1 on date 11/21/22.

I haven’t tested this in Coda, but I think the correct formula should be:

thisRow.Date != [Interaction Log DB].Filter(CurrentValue.Employee = thisRow.Employee).Date.Max()

Why you formula doesn’t work:
Because [Interaction Log DB].Date gives you just the Date column of the table, presented essentially as a list. This when you then chain .Filter(…) on it, it has no Employee column to work with.

Why the proposed formula works (hopefully, as I haven’t tested :sweat_smile:):

doing [Interaction Log DB].Filter() runs the filter on the whole table, which is essentially like saying : it puts the all the rows of table in a list, and goes through that list one item at time calling the item its currently testing CurrentValue. Now since CurrentValue is a row in the table, it has a .Employee attribute that you can test on.
When Filter() finishes, you’re left with a list of rows only with the relevant Employee, and then you can simply take max() on their Date.

3 Likes

Thank you so much, you’re a hero! It worked perfectly.

1 Like