Last active
January 10, 2020 19:30
-
-
Save mdarse/3315d8720514b7f99d8ed491a9db6577 to your computer and use it in GitHub Desktop.
Various Airtable formula snippets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Get Nth word (replace WORD_N to use) | |
TRIM( | |
MID( | |
SUBSTITUTE( | |
{Name}, | |
" ", | |
REPT(" ", LEN({Name})) | |
), | |
(WORD_N - 1) * LEN({Name}) + 1, | |
LEN({Name}) | |
) | |
) | |
-- Reformat phone numbers to ITU format from “Phone number” field | |
-- First, remove various formatting characters (everything that’s not a number), then: | |
-- IF the number is a local french one (10 numbers with a leading 0), we add le +33 prefix | |
-- ELSE IF it’s an international one (00XX, 33XX..), we normalize it to the +XX format | |
-- ELSE we just keep the cleaned number as-is. | |
IF( | |
LEN( | |
TRIM( | |
SUBSTITUTE( | |
" " & SUBSTITUTE( | |
SUBSTITUTE( | |
SUBSTITUTE( | |
SUBSTITUTE( | |
SUBSTITUTE( | |
SUBSTITUTE( | |
SUBSTITUTE( | |
{Téléphone}, | |
"/", ""), | |
".", ""), | |
",", ""), | |
"-", ""), | |
"(", ""), | |
")", ""), | |
" ", ""), | |
" 0", ""))) = 9, | |
"+33" & | |
SUBSTITUTE( | |
" " & SUBSTITUTE( | |
SUBSTITUTE( | |
SUBSTITUTE( | |
SUBSTITUTE( | |
SUBSTITUTE( | |
SUBSTITUTE( | |
SUBSTITUTE( | |
{Téléphone}, | |
"/", ""), | |
".", ""), | |
",", ""), | |
"-", ""), | |
"(", ""), | |
")", ""), | |
" ", ""), | |
" 0", ""), | |
TRIM( | |
SUBSTITUTE( | |
SUBSTITUTE( | |
" " & SUBSTITUTE( | |
SUBSTITUTE( | |
SUBSTITUTE( | |
SUBSTITUTE( | |
SUBSTITUTE( | |
SUBSTITUTE( | |
SUBSTITUTE( | |
{Téléphone}, | |
"/", ""), | |
".", ""), | |
",", ""), | |
"-", ""), | |
"(", ""), | |
")", ""), | |
" ", ""), | |
" 00", " +"), | |
" 33", " +33") | |
) | |
) | |
-- Obfuscate french phone numbers | |
-- The "Phone" column should be the result of the above formula | |
"+33XXXXXXXX" & RIGHT({Phone}, 4) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment