Help

Formula that replaces spaces with underscores and eliminates parentheses

2240 3
cancel
Showing results for 
Search instead for 
Did you mean: 
S_Pacheco-Willi
5 - Automation Enthusiast
5 - Automation Enthusiast

Hi Airtable community! I have a field in my table where I need a formula that outputs the name of a project Slack channel based on the name of the project. However, since Slack only allows for lowercase letters, underscores and dashes, the formula writing is a little complicated.

I need to convert all letters to lowercase, convert spaces to underscores, and not include anything that’s in parentheses.

For example, the project name is: FA22 Project Name / Project Detail (Project Subtitle)

And the output I need is: fa22_project_name_project_detail

Help is greatly appreciated!

3 Replies 3

Hi! The following formula should work if these two assumptions hold true:

  1. There’s only ever one set of parentheses
  2. If there is a set of parentheses, there is always a space in front of the “(”.
    • i.e. it will always be:
      • FA22 Project Name / Project Detail (Project Subtitle)
    • and will never be
      • FA22 Project Name / Project Detail(Project Subtitle)
LOWER(
  SUBSTITUTE(
    REPLACE(
      Name,
      FIND(" (", Name),
      FIND(")", Name),
      ""
    ),
    " ",
    "_"
  )
)
S_Pacheco-Willi
5 - Automation Enthusiast
5 - Automation Enthusiast

Thank you!

So - now realizing something. Not every project name necessarily has parentheses. So the formula worked on every project title WITH parentheses, but not on the ones without. Is there an IF formula that can be added?

Yeap!

LOWER(
  SUBSTITUTE(
    IF(
      FIND(" (", Name),
      REPLACE(
        Name,
        FIND(" (", Name),
        FIND(")", Name),
        ""
      ),
      Name
    )
    ,
    " ",
    "_"
  )
)