Hi there @al_p ! Welcome to Coda and to the Community !
Iāve been trying to reproduce (see examples below ) your setup but, I must say that in its state (with the dates displayed as days) it might leads to āerrorsā .
And here is why :
If you format a Date
field to display the date as a Day of the week
, itās just a display. Behind, thereās still a very precise date.
Which means that when you enter an event in your Events
table and select the Monday 1/11/2021
and then adds another event but select the Monday 1/18/2021
, they will both show up as Mondays
but they are in fact completely different because the dates are not same.
And that could be problematic to filter your lookup
in your other table .
And because when āpre-filteringā your Lookup
field you can only compare āthingsā which have the same formatting (Dates
needs to be compared to Dates
, Text
to Text
, Numbers
to Numbers
, etcā¦ this is true everywhere in Coda, not just in this case), the goal here is to flatten all this so the Lookup
can correctly filter the events.
So I came up with 3 suggestions .
Option 1:
If you really donāt care about the dates underneath those days of the week and youāre completely 100% sure you wonāt need those dates later, what you could do is :
Instead of using a Date
field create a Select List
where the Selectable items
are, simply, the days of the week .
In your other table, once youāve created your Lookup
field (following this path : Right-Click
on the appropriated field ā Change column type
ā Lookup
(somewhere near the bottom of the menu) ā select your table Events
) go to Lookup options
. Once there, look for Item settings
then go to Filter
. In the dropdown menu, select Custom filter
and click on Add filter
.
Coda will invite you to select the field to use to filter the Lookup
and here, you should choose Dates
.
As you want this filter apart from both tables, under Dates
thereās another dropdown menu where you should see the option Uses interactive filter
(more info). Click on that and then on Create Control
.
Coda will automatically create a Multi-select
control on the canvas of your doc, gathering the āDates
ā youāve already put in your Events
table and youāll be able to select any Dates
in that Control
to pre-filter the Events
in your Lookup
field .
Another way to get to the same results would be to create yourself that (Multi)-Select Control
on the canvas (which I did in my example) and select that Control
in Uses interactive filter
.
Option 2
After all that, If youāre actually not certain that you wonāt need those āprecise datesā later (see my other example below), the other suggestion I can make is to keep the Date
format of your Dates
field in your Events
table but display it as classic date. And then add a text field to this table.
In this new field, just add a WeekdayName()
formula (more info) that will give you the name of the day for the date you put in your date field :
thisRow.Date.WeekdayName()
The rest follow the same Interactive filter
principle but using this new text field instead of the date
field
Option 3
This is a bit more complex but it uses your (I think ) actual setup (with you Dates
formatted as Day of the week
)
As I said above, you can only compared āthingsā with the same format.
In this case, your Dates
are still Dates
but they might be different even if they look the same.
So, to be able to pre-filter the items in the Lookup
field, this time, youāll need to create a Select Control
on the canvas which will be used to filter the items in the Lookup
later but also to convert the Date
format into a Text
format so whatever Monday
you select in your Events
table (1/11/2021
or 1/18/2021
) it will interpreted as a Monday
.
In the Selectable items
of this Select Control
you should put a formula looking like this :
[YourEventsTable].Dates.FormulaMap(CurrentValue.WeekdayName()).Unique()
What it does is list all your dates in your Events
table and for each (CurrentValue
) dates in that list (FormulaMap()) gets the WeekdayName()
(as the result of a WeekdayName()
formula is given in a Text
format). Then, it only keeps the Unique()
results.
Now, in your Lookup
field, in the Item settings
, instead of just select or create an interactive filter, youāll need to use its counterpart, the formula Matches()
:
WeekdayName(Dates).Matches([Select the day])
What it does is gets the WeekdayName()
from your dates in your Events
table and convert them as a Text
format and then check if any events matches the option selected in your new canvas Select Control
. And it works because now both are in a Text
format
And, thatās it
Donāt hesitate, if something is not clear .
Itās not always easy to explain in a simple way all those things , so all this may lack clarity .
Small add-on to the Option 3 : If you need more help to understand how FormulaMap()
works and what it does, you can check this post (which helped me a lot with this specific formula ) :