Hi all,
I need to generate a 4 digit code from the year a record was created and how many records have come before in that year.
E.g the 5th record that has been created in 2023 = 2305.
I have reformatted the referral date
Hi all,
I need to generate a 4 digit code from the year a record was created and how many records have come before in that year.
E.g the 5th record that has been created in 2023 = 2305.
I have reformatted the referral date
@user9658457988 wrote:Hi all,
I need to generate a 4 digit code from the year a record was created and how many records have come before in that year.
E.g the 5th record that has been created in 2023 = 2305.
I have reformatted the referral date
DATETIME_FORMAT({Date of Referral},"YY") but unable to get a COUNTIF function to work to count how many referrals have been made before this one where the referral date is in the same year.
Here's the formula to generate the 4-digit code:
=TEXT(DATETIME_FORMAT({Date of Referral},"YY")&COUNTIFS({Date of Referral},">="&{Date of Referral},{Date of Referral},"<="&EOMONTH({Date of Referral},0)),"0000")
Explanation:
Example:
If the "Date of Referral" for a record is "2023-07-15" and there are 5 records with referral dates in 2023 up to and including July 15th, the formula will generate the code "2305".
Note:
This formula should effectively generate the 4-digit code you require.
@user9658457988 wrote:Hi all,
I need to generate a 4 digit code from the year a record was created and how many records have come before in that year.
E.g the 5th record that has been created in 2023 = 2305.
I have reformatted the referral date
DATETIME_FORMAT({Date of Referral},"YY") but unable to get a COUNTIF function to work to count how many referrals have been made before this one where the referral date is in the same year.
Here's the formula to generate the 4-digit code:
=TEXT(DATETIME_FORMAT({Date of Referral},"YY")&COUNTIFS({Date of Referral},">="&{Date of Referral},{Date of Referral},"<="&EOMONTH({Date of Referral},0)),"0000")
Explanation:
Example:
If the "Date of Referral" for a record is "2023-07-15" and there are 5 records with referral dates in 2023 up to and including July 15th, the formula will generate the code "2305".
Note:
This formula should effectively generate the 4-digit code you require.
Thanks for the explanation!
Air table doesn't support countifs, eomonth or text functions so this formula doesn't work. Do you have a work around for these functions?
I am completely new to airtable I just tried this out in what I think is a similar situation and am getting error message unfortunately…
I am trying to create a unique code for the number of seed collections (by species) that includes the year. So if we had three collections of the same species in the same year, it would say 2025-3.
This is also somewhat complicated by the fact that we will have seed we collect ourselves and seed we purchase… Right now I am working on developing two separate tables for seed sources. Maybe I need to finish those first before I create the “Seed Record ID”
As mentioned above, Airtable doesn’t support COUNTIF (or EOMONTH). There’s a handy dandy Formula Playground base available in the support docs (which I would link to but the Support Center seems down right now...)
Anywho, the other thing to consider is that generally speaking formula fields only engage with data inside their own record (row). Dunno if it’s helpful to frame like this, but formulas only move horizontally not vertically. So the way this is set up in the screenshot, there's only one date it’s pulling all that information from, and even if that date is repeated in other rows, it’s not going to tally those together. The way you do something like that is to utilize a new table and a linked record field for collection dates, and then you can lookup/rollup that information to utilize for formulas.
I think this link should work to get to the formula playground.
I’ve found it very useful.
This question comes up several time a year, and I’ve seen a lot of interesting “solutions”, but aside from scripting I don’t think there is an easy solution. What
As mentioned above, Airtable doesn’t support COUNTIF (or EOMONTH). There’s a handy dandy Formula Playground base available in the support docs (which I would link to but the Support Center seems down right now...)
Anywho, the other thing to consider is that generally speaking formula fields only engage with data inside their own record (row). Dunno if it’s helpful to frame like this, but formulas only move horizontally not vertically. So the way this is set up in the screenshot, there's only one date it’s pulling all that information from, and even if that date is repeated in other rows, it’s not going to tally those together. The way you do something like that is to utilize a new table and a linked record field for collection dates, and then you can lookup/rollup that information to utilize for formulas.
This is so helpful! thanks
That was my hunch when I was working on this and posted the question. Somehow I missed that detail about the formulas in the post above. I did see the formula playground link earlier and appreciate knowing about it!! I’ve only been at this about a week and am still on the steep part of the learning curve.
Ah and now Support Center is working again for me. Thanks
As Bill mentioned too, you might be able to hack something together via automations and scripting, but that’s beyond me. Just figured that’d be some helpful insight as it sounds like your still assembling your bases and workspace.
For what it’s worth, a simple automation that should work if you are always entering the data in the current year.
Add a field for the number - format it with no decimals. If you don’t have a date field for the entry make one or use the created date field.
For the Automation
Trigger - When a new record is created.
Action One - Find all records the the date your using falling in the current year.
Action Two - Update the created record from the trigger with the count of records from the Find Records step.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.