Hidden Tana Feature: Formula Fields

tana

If you’re just interested in the how-to – you can jump past my context.
If you’re just looking for the formula function reference, you can jump to that, too.

Tana Outliner is a pretty cool piece of note-taking/“personal knowledge management " software – despite their heavy advertisement of AI interactivity – which manages mostly to deliver on the promise of letting you do very little work regarding data capture, while still making data retrieval possible.

It’s nowhere near as “infinitely flexible” as tools like Obsidian; but in trading off that flexibility, it also frees you from thinking of things like “Where in my filesystem did I put that note?”. Instead, it’s an ad-hoc “knowledge database” that successfully shapes relations around small bits of trivial data entry.

This database model makes you feel like Tana should be the kind of database you can easily query for things like “How much money did I spend on projects that I started but didn’t finish, this year?”, or – if you’re like my wife – “How many Smash matches did I win while playing as Corrin?”.

Tana features live search nodes that can help you do simple queries like “show all of the notes tagged #project with a status field set to unfinished and a start date within this year, and sum the cost column”; and that usually works pretty well – but it doesn’t given you much control over how the data is displayed, or allow you to have fields that are based on the values of other fields. This seems like a pretty glaring omission, especially when you look at the competition from omnipresent products like Notion.

Luckily, most of Tana’s internal features are implemented in Tana, even when they’re not quite surfaced that way. That means that we can take advantage of the same internals that drive things like Tana’s Live Search – and its sum columns to squeeze a bit more out of Tana.

Formula ‘Fields’

To accomplish fields whose values are based on other fields, we’ll start off by creating a Tana field, e.g. by using the shortcut ‘>’ on a new node. Then, we’ll do something that’s surprisingly well-surfaced for how undocumented it is: we’ll open the command palette (e.g. with Ctrl+K or Cmd+K) and then select “Set Formula = Yes”.

close up of a tana figure now bearing a new icon that appears as an 'fx', titled 'Show forumla' on a screen reader

Note that this field no longer has a value to be edited: while we can give it a title, the area to the right of the ‘fx’ show formula button has changed into something that will – in a moment – show the output of the formula we’re creating.

The real magic happens when we click that show formula button – and the field suddenly becomes editable again. Now, instead of entering normal data, Tana will process each node as a string function name; with function arguments provided as children of the node containing the function name. Spoiler alert: the available functions aren’t documented in Tana, but I’ve documented them below.

Let’s say we had two existing fields – we’ll call them rectangle length and rectangle width – and we wanted to compute the rectangle area, which we can get by multiplying these two fields together. We’ll use the multiply function, which we can enter by typing in the multiply function ( or its shorthand of a single *) as our function node:

close up of two fields -- rectangle length with a value of 10, and rectangle width with a value of 20, and our formula field, in edit mode, with just an asterisk function name as its value

This function node will multiply any values present in its children – which can be any of three things:

In our example, we’ll add in two references to the field values captured above by holding alt (option on macOS) and dragging the field values into our formula:

our same formula node, but now with two Tana references to the _10_ and _20_ we had entered above as children of the asterisk node

If we then exit formula-entry mode by clicking the show formula button again, we’re now greeted with a cheerful multiplication of our two values:

our formula node now shows the value '200', a multiplication of our references

Of course, this isn’t nearly as useful as it could be – since those references always refer to those two particular field values. What if we want to use this in a template, e.g. in the content we specify for a supertag?

Referencing other Fields

Fortunately, Tana has functions that allow us to look up the value of a particular field on a relevant node, which is aptly named lookup. Instead of the direct references to our field values, we can return to show formula mode, and insert a node with the text lookup:

the same fornula node, but with both references replaced by the simple string 'lookup'

Note: I’ve used multiply instead of an asterisk, here – but the two are aliases, and thus equivalent. You can use either one, and in this document I’ll alternate between them to drive that point home.

Since lookup is a function that takes an argument itself, we’ll need to child nodes to each lookup indicating which field we’d like to get the value of. These require field references – which we can get in one of two ways:

We’ll add field references to our length and width fields, each specified as children (‘arguments’) of our lookup function node:

the same formula node, but with both 'lookup' functions now having a field reference as a child node

If we exit show formula mode, we now have successfully computed the area of our rectangle – and using only the local field values!

our completed formula node, now showing that it's computed 10 * 20 to 200

Note: technically, lookup takes two arguments as child nodes; but the second is optional. Helpfully, if not provided, it defaults to referencing the parent node that our formula field belongs to; equivalent to providing the SELF function defined below as our second argument.

Formulas work live

A cool feature of formula fields is that the work live – which means that if we click on after our rectangle width of 20 and backspace away the last zero, Tana instantly updates our derived field:

our formula node updates live, so it now succesfully shows that 10 * 2 is 20

Formulas can reference formulas

Another cool feature of formula fields is that they’re still fields – which means we can use them directly in other computations. So, if we wanted to, we could easily figure out the volume of a prism with a base of this rectangle:

the same formula components, but we've added a 'prism height' field with a value of 2, and then a new formula node that computes the product of a LOOKUP of our original formula node, and the new field we added

If we exit out of show formula mode, we can see that everything’s worked exactly as we’d hoped:

exiting show formula mode shows the result we'd hope for: 20 * 10 * 2 = 400

Formula Functions

Unfortunately, as mentioned above, formula node functionality is currently entirely undocumented. To make up for that, I’ve copy-pasted my own notes on how each of the various formula functions work, exported directly from my Tana workspace:

The order here is preserved from the way they’re defined in Tana’s javascript; which seems to group related functions.


The following functions seem to exist on formula nodes, with child nodes being their arguments. Functions are a node with that contains only their name as a string, any child nodes on the function node are taken as arguments.