Jun 26, 2023 04:15 PM
I have a User field that allows multiple users to be tagged. I'd like to write a formula that will pull those people's first names into a comma-delimited list. I came up with the following:
LEFT({Users}, FIND(" ", {Users})-1)
...which does the trick if there's just one person tagged. But if multiple people are tagged, the formula only returns the first name of the first person.
Is there a way to make this work? I have a feeling this might require a REGEX formula though I'm not so clear on how they work...
Thank you!
Jun 26, 2023 05:45 PM
Hello, @kts
Yes, it is true that REGEX is difficult to understand
Can you show a few examples of inputs and ideal outputs?
Jun 29, 2023 08:57 AM
Jun 29, 2023 05:52 PM
A simple way to do this is to create a "Short Name" formula field in the "Users" table and put your formula in it.
Then, from the linked table, you can lookup or rollup the "Short Name" field to get the list.
Jun 30, 2023 02:37 PM
That makes sense, but in this case, I'm using a Collaborator/User field that links directly to Airtable users, rather than using a linked record to a separate Team table.
Jul 01, 2023 03:23 AM - edited Jul 01, 2023 06:39 AM
Oh, yes, it was a user field
I know it's weird, but how about this!
REGEX_REPLACE(
LEFT(REGEX_EXTRACT(Users,"([^ ]* ?){1}"),3)&", "&
LEFT(REGEX_EXTRACT(Users,"([^ ]* ?){3}"),3)&", "&
LEFT(REGEX_EXTRACT(Users,"([^ ]* ?){5}"),3)&", "&
LEFT(REGEX_EXTRACT(Users,"([^ ]* ?){7}"),3)&", "&
LEFT(REGEX_EXTRACT(Users,"([^ ]* ?){9}"),3)&", "&
LEFT(REGEX_EXTRACT(Users,"([^ ]* ?){11}"),3)
,"(, ){2,}|, $","")
The number needs to be increased by 2 for each maximum number of users.