d\Does anyone know how to use placeholder in named formulas:
say I write a formula named MyFormula and the formula looks something like
A + B. How can I pass variables A and B to my formula and how do I write the variables? I have been trying things like [%1] + [%2] and other variations, but I am not succeeding yet.
Hi @joost_mineur. What I’ve done is set up a table called variables
with columns [variable]
and [value]
. Lets say we have a variable/value pair of ‘amendment’ and ‘2’.
Then you can have a formula anywhere in the doc
=concat("My favorite part of the bill of rights is amendment ",@amendment.value,".")
which in this case outputs
My favorite part of the bill of rights is amendment 2.
Changing [value]
will update the output. This solution stacks with a user table, cross doc, etc. Good luck!
Hello Jogh,
Thank you for your reply, but if I understand you correctly you are returning a value that belongs toe a variable. That is not what I am trying to achieve. In my example (Formula is A + B) I never now what A and B are going to be - they are not based on any know facts. A and B are each the result of external input, be it a temperature, a time, a date, etc. In some other programming languages I was able to do the following:
Define Function MyFunction Var 1 Var 2 Var 3 (etc.)
ResultField = Var 1 + Var 2 + Var 3
ret ResultField
Then I would call my function an pass along anywhere from one to three parameters:
MyFunction(1,2,3)
which would return 6
Or, say the following variables exist:
varApples = 3
varPears = 3
MyFunction(varAppels,varPears)
which would return 6
This is what I am trying to accomplish and it cannot be done with a prebuild table.
Anyone?
Greetings,
Joost
Hi @joost_mineur,
Your point is clear.
Full-fledged parametrised functions are not yet part of Coda formulas
Have a look at
CurrentValue in Named Formulas and FormulaMap - #2 by Jason_Tamulonis
I hope with you we can see something not to far from now…
Cheers!