I’m trying to make a billing document for me, and I’m a little stuck on one field.
I have a column which is 'Last Paid" - a date field. I have another column ‘Pay Period’ which I’d like to create a formula for. If Last Paid is after the 14th of x month, but before the 15th of y month, then 'Pay Period x - y" would fill in the Pay Period column.
I had this set up
“If(thisRow.[Last Paid]>Date(2021,10,14).And(thisRow.[Last Paid]>Date(2021,11,14)),“Pay Period 15 Oct - 14 Nov 2021”,”"), however, it fills in the same thing for every field no matter that the date is. Any help is appreciated
hi Nikki, we did not see you for a while, good to have you back. I’d like to propose a dynamic solution like below. The 14 is hard coded, but of course you can replace this by a variable by referencing a column that holds the day number.
You have two errors in your formula. You’re writing .And() to the result of Date(...), not the comparison. Also you have your second comparison operator wrong: > instead of <.
It should’ve been If((thisRow.[Last Paid] > Date(2021,10,14)).And(thisRow.[Last Paid] < Date(2021,11,14))
However —
Using logical functions such as Or() and And() is discouraged in Coda. It is better and more efficient to use logical operators instead:
If(
thisRow.[Last Paid] > Date(2021,10,14)
AND thisRow.[Last Paid] < Date(2021,11,14),
"Pay Period 15 Oct - 14 Nov 2021",
""
)
And yeah, in general a dynamic solution would be better. Not like Christian suggested, but with a table of periods. Examine this sample:
P.S. Oh, I just noticed the “after the 15th” requirement. Well, you could adjust my solution to automatically pre-fill period dates as well.