Hey everyone! I’m new to Airtable and I’m stuck on something. I need to figure out how to show the right quarter and year based on a date in a cell. Our quarters are weird - they start in September.
I tried using a bunch of IF statements, but it’s getting messy. Here’s what I’ve got so far:
IF([Date] = 'Oct-19', 'Q1 Y2',
IF([Date] = 'Nov-19', 'Q1 Y2',
IF([Date] = 'Dec-19', 'Q2 Y2')))
But this is going to be huge if I do it for all months. Plus, I’ll need to change it every year. Is there a smarter way to do this? Maybe something that can handle the year change automatically?
I’m open to any ideas or tricks you might have. Thanks for your help!
Have you considered using a custom script for this? I’ve found that when dealing with complex date calculations, especially non-standard fiscal quarters, writing a custom script can be much more efficient and flexible than formula-based solutions.
You could create a script that takes the date as input, calculates the appropriate quarter and year based on your specific fiscal calendar, and returns the result. This way, you’d have a reusable function that works for any date without needing annual updates.
The script could handle the year rollover logic and quarter assignments in a centralized place, making it easier to maintain and modify if needed. Plus, it would be more performant for large datasets compared to complex nested formulas.
If you’re not comfortable with scripting, Airtable’s scripting block might be a good place to start, as it provides a user-friendly environment for writing and testing custom JavaScript functions.
I faced a similar challenge with non-standard quarters in my work. Instead of using a long chain of IF statements, I found it more efficient to use a DATETIME_FORMAT function combined with a lookup table.
First, create a table with your custom quarter definitions. Then, use DATETIME_FORMAT to extract the month and year from your date field. Finally, use a VLOOKUP to match the month to the correct quarter.
Something like this:
VLOOKUP(
DATETIME_FORMAT([Date], 'M'),
'Quarter Lookup Table',
'Month',
'Quarter'
)
& ' Y' &
IF(
DATETIME_FORMAT([Date], 'M') < 9,
DATETIME_FORMAT([Date], 'YYYY'),
DATETIME_FORMAT([Date], 'YYYY') + 1
)
This approach is more maintainable and automatically handles year changes. You’ll only need to update the lookup table if your quarter definitions ever change.
hey olivia, try DATETIME_DIFF! set sept 1, 2019 as base and calc month diff. then, use floor and mod to get quarter: LET(m, DATETIME_DIFF(‘2019-09-01’, [Date], ‘months’)). result like ‘Q’ & (MOD(FLOOR(m/3),4)+1) & ’ Y’ & (FLOOR(m/12)+1).