Template Column - Conditionals/Boolean

Greetings,

I have a template column for a calculated description from other columns. I need some conditional logic on this where if a boolean column is true to return specific text and the data of another column. I’m seeking expertise on how best to achieve this within Glide.

I’m thinking to achieve this with Glide that I’ll have to have additional template column per boolean column at minimum to achieve this. I just want to make sure that there’s not a better way as in a coded solution this would just be some IF statements.

Example:
Is it a… 12 foot beam? 10 foot beam? 12 foot beam with 3 bolts? 10 foot beam with 2 bolts?

Column A (Text) - Type
Column B (Number) - Length
Column B (Boolean) - Bolts Required?
Column C (Number) - Number of Bolts Required

If you want to get fancy, you can go the javascript route. To keep it simpler, you can use a series of IF columns and template columns.

So I assume the biggest factor is whether or not bolts are required, and the text that goes along with that?

1 Like

One thing that might work is to dynamically build a template with an IF column, then use that template in a template column.

So you could set up an IF column like this:

If Bolts Required is true Then 
     "{{length}} foot beam with {{bolts}} bolts"
Else
     "{{length}} foot beam"

Then set the result of the IF column as the template in a template column. Add your replacements and it should dynamically show the correct text based on beam length and whether or not bolts are required.

The alternative would be a javascript column where you pass in the variables and it returns the text. So pretty two columns vs one column to achieve the same result.

3 Likes

Thanks Jeff on both replies. I didn’t realize Javascript was available as an option with the Experimental Features. Very cool. Also… there are Excel Formulas there too - pretty interesting!

I’m trying hard to make any solution I develop with Glide to be understandable by those that are advanced Excel users but not necessarily code “literate”. Even when it seems silly to do something like these additional columns. One of the challenges with low-code are these types of edge cases in advanced functionality and what makes an expert community like this invaluable.

3 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.