Storing the Result of a Formula in a Variable

Is there any way , we can store the value of a formula in a variable ? I have this code below.

If((Codes.Filter(Jurisdiction= thisRow.Jurisdiction AND ([Adopts Publication].Abbreviation =thisRow.Pub)).[Effective Date].Unique().Count()<=(1)), ‘NULL’, ‘DoOtherThings’)

I want to store the value of the formula below in a variable, so I can avoid writing long codes that will complicate my formula :

Codes.Filter(Jurisdiction= thisRow.Jurisdiction AND ([Adopts Publication].Abbreviation =thisRow.Pub)).[Effective Date].Unique().List()

:wave: Hey there!

Im not sure exactly what you are trying to do, but two things come to mind:

(1) WithName()

WithName() is a wonderful formula that allows you to write a complex longer formula and then give it a short name to reference it by.

Once you create it’s short name you can reference that anywhere else within the same formula

Heres some documentation on withName(): [DOCUMENTATION]

Heres a screenshot of it working. Noticed how I named this longer filter() formula as allPeople and then was able to reference it twice later on

(2) Named Canvas Variables
You can write any formulas into the canvas and then give those a Name - that named formula can then be referenced anywhere within your docs at any time and can utilize its ouput. I normally keep a dedicated hidden page in all my docs just for this purpose.

I can explain one use case around that very thing in this video where I create a named variable titled giveAccess which then allows the doc creator to filter tables conditionally and easily based on who is logged into the doc.

Always name your canvas based variables!

5 Likes

Topic two is completely new to me.

10:07 PM my learning for the day… :slight_smile:

2 Likes

Such a great help. Writing formulas in Coda will be very messy without this.

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