Search code examples
if-statementconcatenationformulaairtable

AirTable Formula


I am working on an AirTable. Essentially I am concatenating a series of cells with the end goal of generating a filename with the text in those cells. However, not all file names have the same attributes.

So if you notice in the formula bellow, if the file doesn't have a "DynamicSubitle" it will leave a double underscore. How could I avoid that?

Here is my formula:

CONCATENATE(Airline, "_", Trim, "_", Ratio, "_", Episode, {Language 1}, {Language 2}, {Language 3}, {Language 4}, {Language 5}, "_", {Dynamic Subtitle 1}, "_", Version, "_", {Mpeg Type}, "", Extension)

Thanks everyone!


Solution

  • It can be possible, but you have to write a complex if-else formula for this. Pseudocode, will be like first check for empty value if there is empty value don't concatenate else concatenate value with underscore. Formula will be like,

    CONCATENATE(
       IF(Airline = "","",CONCATENATE(Airline,"_")),
       IF(Trim = "","",CONCATENATE(Trim,"_")),
       IF(Ratio = "","",CONCATENATE(Ratio,"_")),
       ...all other values...,
    
       IF({Dynamic Subtitle 1} = "","",CONCATENATE({Dynamic Subtitle 1},"_")),
    
       ...all other values...
    )