Obsidian Bases support
mdgrid opens an Obsidian Bases file (.base) and shows its table views. .base has no published grammar and its meaning can change between Obsidian versions, so mdgrid aims to get the commonly used parts of the table view right and to say plainly when it meets something it does not understand. It never guesses rows or values.
This page lists what mdgrid reads and what it does not. The lists of functions, methods and file properties below are checked by tests against the expression parser (tests/test_bases_docs.rs): adding a function to the parser without listing it here, or listing a function the parser rejects, fails the tests.
mdgrid never changes an existing .base file. Exporting a view writes a new .base file under a name you choose instead. Unknown keys are ignored rather than reported as errors.
Which notes are searched
The rows come from the root folder the .base belongs to. mdgrid finds the root folder by walking up from the .base file’s folder to the nearest folder that contains .obsidian/, then reads every note under it. If no .obsidian/ folder is found (for example, a root folder copied without its settings), only the .base file’s own folder is searched, so a filter such as file.inFolder("Projects") can match nothing. When that happens and the view is empty, mdgrid says which folder it searched (on the bottom line, and on stderr with --print). To fix it, create an empty .obsidian/ folder in the root folder.
Like Obsidian, mdgrid does not look inside folders whose names start with . (such as .obsidian, .git and .trash). It also skips node_modules, so opening a code repository does not list the documentation of its dependencies. A folder you name on the command line is always searched, even if its name starts with ..
Keys read
Top level:
| Key | What mdgrid does with it |
|---|---|
filters | Applied to every view, combined with the view’s own filters by AND. |
formulas | Named expressions. Each one can be shown as a column formula.<name>, used for sorting and grouping, and referenced from other expressions. |
properties | Only displayName, which becomes the column title. Every other place that names the column uses it too: group headings, the condition chips of the view band, the kanban and gantt titles, the fields of the new note window and the columns of the tree screen. Values written to notes, expressions and settings keep the original key. Keys may be written as status or note.status. Columns without a displayName get Obsidian’s default titles (a formula column shows the formula’s name, file.name shows file name, file.ctime shows created time, and so on). The keys of --print --format json use the same titles. |
views | The list of views. Each view becomes a tab; the first view opens at startup. |
summaries | Formula summaries (such as values.mean()) are not evaluated. A view that uses one still opens, and the bottom line names it as unsupported. See Summaries. |
Inside a view:
| Key | What mdgrid does with it |
|---|---|
type | Must be table. See View types. |
name | The tab name. |
filters | The view’s own filters. |
order | The columns, in order: note properties (status or note.status), file.* and formula.*. Without order, the columns are file.name followed by every frontmatter key found in the notes. |
sort | A list of property and direction (ASC or DESC, case-insensitive; anything else means ASC). Earlier entries win. |
groupBy | property and direction. Rows are gathered under one heading per value; empty values go under (empty) ((空) in Japanese). Within a group, rows follow sort. |
limit | A whole number. Applied last, to the total number of rows. |
summaries | A map from a column (estimate, note.estimate, file.* or formula.*) to a built-in summary name. See Summaries. |
summary_labels | A key mdgrid adds (Obsidian ignores it). A map from a column to the name its summary shows instead of the built-in one, in every language: finished: Books makes Filled 13 read Books 13. Only text names are read. See Summaries. |
tab_break | A key mdgrid adds (Obsidian ignores it). With true, the row of tabs breaks before this tab. When a shown tab other than the first has it, all tabs go on rows below the search box, whatever the terminal width and display.tab_wrap, and a new row starts here (a row that does not fit wraps within itself). On a hidden tab, the row breaks at the next shown tab. For example, keep the tabs that filter by status and the tabs that filter by due date on separate rows. |
filters (both at the top level and in a view) is either an expression string or a map with and, or and not, each holding a list of expression strings or further maps. Several of these keys in one map are combined by AND. not keeps a row when none of its entries is true. Any other key in such a map, or a value of another shape, makes the view fail to open (see Not supported). A filter keeps a row only when its expression is true under the same rules as if: null, false, 0, and an empty string are false.
Sorting by a note property puts values that fit the column’s type first (in the given direction), then values that do not fit (by text, A to Z), then empty values, whatever the direction. Sorting by formula.* or file.* has no column type: values of different types are ordered by type (booleans, numbers, durations, dates and date-times, strings, lists), and DESC reverses that whole order; empty values (null, an empty string, an empty list) still come last. Rows with equal keys keep their original order.
Everything else in the file (for example columnSize, rowHeight, and keys mdgrid does not know) is ignored, but never removed, because mdgrid does not change the file.
View types
Only table is supported. A view with another type (cards, list, map, a plugin’s view, …) or with no type does not open: its tab is still listed, the table area shows the reason, for example cards view "Gallery" is not supported (mdgrid shows table views only), and the bottom line tells you to switch with [ ]. mdgrid does not try to draw these views as a table.
Operators
| Operator | Meaning |
|---|---|
== != | Equal and not equal, for any type. Values of different types are not equal, except dates (see below). === and !== are read as == and !=. |
< <= > >= | Order of numbers, strings, booleans, durations, and dates and date-times. A duration compares with a number as milliseconds. Other mixes of types give null. |
&& || ! | And, or, not, using the truthiness rules of if. |
+ - * / % | Arithmetic on numbers. + also joins strings (and a string with a number). Division by zero and overflow give null. |
-x +x | Unary minus and plus. |
( ) | Grouping. * / % bind tighter than + -, then comparisons, then == !=, then &&, then ||. Operators of the same level group from the left. |
x[i] | Item i (counted from 0) of a list. |
Date arithmetic:
- date
+or-a duration string, such asdue + "1d",today() - "2 weeks", ornow() + "1d 3h". Units:y/year,M/month,w/week,d/day,h/hour,m/min/minute,s/sec/second(plurals andyr,hr,hrs,mins,secsalso work). Months and years follow the calendar; a day past the end of the month becomes the last day of that month. - date
+or-a value fromduration(), such asdue + duration("1d").duration()values can also be added to and subtracted from each other. - date
-date gives a duration in milliseconds. - duration
*or/a number gives a duration (a duration under one second shows asms). To get a number of days, usenumber():number(due - today()) / 86400000.
Values:
- Literals: strings in
"..."or'...'(with\n,\t,\rescapes), numbers,true,false,null, and lists[a, b]. - References: a bare name or
note.nameis a frontmatter key;note["a b"]reaches a key with spaces.formula.name(orformula["name"]) is a formula.file.nameand the rest are listed under File properties. A missing key givesnull. - A frontmatter string in the form
YYYY-MM-DDis read as a date, andYYYY-MM-DDTHH:MM(:SS)as a date-time in local time, as Obsidian does.today()andnow()also use the local time zone. When one side of a comparison or of+/-is a date and the other a string, the string is read as a date too.
An operation on types that do not fit gives null instead of stopping.
Functions
if(condition, then, else):thenwhenconditionis true, otherwiseelse.elsemay be left out, givingnull.date(text): readsYYYY-MM-DDas a date andYYYY-MM-DDTHH:MM(:SS)as a date-time; a date passes through; anything else givesnull.now(): the current date and time.today(): today’s date.duration(text): reads a duration string such as"1d"or"2 weeks"as milliseconds (a month counts as 30 days and a year as 365).number(value): a duration as milliseconds, a date or date-time as milliseconds since 1970-01-01,true/falseas 1/0, and text that reads as a number as that number; anything else isnull.max(a, b, ...): the largest of the numbers;nullif any value is not a number.min(a, b, ...): the smallest of the numbers;nullif any value is not a number.list(value): a list stays as it is; any other value becomes a list with that one item.
Methods
contains(value): for a string, whether it contains the text; for a list, whether it has an equal item.containsAll(a, b, ...): whether every value is contained.containsAny(a, b, ...): whether at least one value is contained.isEmpty(): true fornull, an empty string and an empty list.toString(): the value as text.lower(): a string in lower case;nullfor anything else.upper(): a string in upper case, sostatus.upper() == "ACTIVE"works as a filter.title(): a string with the first letter of each word in upper case and the rest in lower case.trim(): a string without white space at both ends.startsWith(text): whether a string starts with the text.endsWith(text): whether a string ends with the text.slice(start, end): part of a string or a list, fromstartup to (not including)end.endmay be left out; negative numbers count from the end.replace(pattern, replacement): a string with every occurrence of the textpatternreplaced. Regular expressions are not supported.split(separator, n): a string cut at the textseparatorinto a list (at mostnitems when given). Regular expressions are not supported.reverse(): a list in reverse order, or a string with its characters reversed.round(digits): a number rounded to the nearest whole number, or todigitsdecimal places.floor(): a number rounded down.ceil(): a number rounded up.abs(): the absolute value of a number.date(): a date or date-time as a date (the time dropped).time(): the time of a date or date-time asHH:mm:ss(00:00:00for a date).format(pattern): a date or date-time as text. The pattern uses Moment’s tokens (English names):YYYYYYQMMMMMMMMMMDDDDDDDDDDoDddddddddddeEHHHhhhAammssSSSXx, ISO weeksGGGGWWW, and Sunday-start weeksggggwww(the week with January 1 is week 1). Other characters, and anything inside[...], are copied as they are.relative(): how far a date is from today, or a date-time from now, as text in mdgrid’s language:in 14 days,5 days ago,today,in 3 months,in 1 year. Less than a calendar month is counted in days, less than twelve months in months, and beyond that in years; a part of a month or year is dropped. A date-time less than a day away is counted in hours, less than an hour in minutes, and less than a minute isnow. Anything that is not a date givesnull. The wording is mdgrid’s own and may differ from what Obsidian shows, so use it to show a column and compare dates with<andtoday()in filters.nextRun()(added by mdgrid; not in Obsidian): from a routine’s repeat rule (weekly mon,monthly lastand so on; see Create routine runs for the forms), the nearest run date from today on (today when today is a run day), as a date. Forevery 3d, pass the start date:recurrence.nextRun(start). A rule that cannot be read, an empty value, oreverywithout a start gives an empty value. Use it in a formula column to show a routine’s next run without writing it into the note.join(separator): the items of a list as text joined by the separator.unique(): a list without repeated items (the first of each is kept).sort(): a list from smallest to largest.flat(): a list with the lists inside it opened up by one level.asFile(): the note a link points to. It takes a value that is a whole link ([[name]],[text](https://github.com/S6U5/mdgrid/blob/main/docs/path.md), or a path) and an item offile.backlinks(a path from the root folder), and finds the note the same way asfile.links. A link that matches no note, and any other value, givenull. See Linked notes.filter(condition): the items of a list for whichconditionis true. Insidecondition,valueis the item andindexits position, counted from 0:[1, 2, 3, 4].filter(value > 2)gives[3, 4]. Elsewhere, and written asnote.value,valueis still a frontmatter key.map(expression): a list withexpressionworked out for each item, using the samevalueandindex:[1, 2, 3].map(value * 10)gives[10, 20, 30].reduce(expression, start): one value made from a list.accstarts asstartand becomesexpressionfor each item in turn:[1, 2, 3].reduce(acc + value, 0)gives6.max()(added by mdgrid; Obsidian only hasmax(a, b, ...)for numbers): the largest number in a list, or, when the list has no numbers, its latest date or date-time. Other items are skipped, and a list with nothing to compare givesnull.min()(added by mdgrid): the smallest number in a list, or the earliest date or date-time, in the same way asmax().sum()(added by mdgrid): the total of the numbers in a list, skipping other items (0when there are none).length: the number of characters of a string or items of a list, written without parentheses (tags.length).year: the year of a date or date-time, written without parentheses (due.year). The same goes for the five below.month: the month (1 to 12).day: the day of the month.hour: the hour (0 for a date).minute: the minute (0 for a date).second: the second (0 for a date).
File properties
Values:
file.name: the file name with its extension.file.basename: the file name without the extension.file.ext: the extension.file.path: the path from the root folder.file.folder: the folder from the root folder.file.size: the size in bytes.file.mtime: the time the file was last modified.file.ctime: the time the file was created.file.tags: the tags of the note: the frontmattertags(alsotag,Tags, in any case; a list, or text split at commas and spaces) and the#tagsin the body.file.links: the notes this note links to, as a list. Links are taken from the body and from frontmatter values:[[name]],[[name|text]],[[name#heading]],![[name]]and[text](https://github.com/S6U5/mdgrid/blob/main/docs/path.md). Links inside code blocks and inline code are skipped, as are web addresses. Each link becomes the path of the target note from the root folder without.md(for examplesub/c). The target is the note at that path from the root folder (a[text](https://github.com/S6U5/mdgrid/blob/main/docs/path)link first tries the path relative to the note’s folder); otherwise the note with that name, and when several notes share the name, the one nearest the root folder (then the shortest path). Case does not matter. A link that matches no note stays as written ([[missing]]givesmissing). Each target is listed once.file.backlinks: the notes that link to this note, as a list of their paths without.md(the same link rules asfile.links).
Functions on file:
file.hasTag(tag, ...): true when the note has any of the tags. A leading#is ignored, case does not matter, and a nested taga/balso matchesa.file.inFolder(folder): true when the note is in that folder or one of its subfolders.file.hasProperty(name): true when the frontmatter has that key.file.hasLink(note): true when the note links tonote(a name, a path, orthis.file).file.linkedFrom(key, ...)(added by mdgrid; not in Obsidian): the notes whose frontmatterkey(any of the keys given) links to this note, as a list of notes in path order. Links in the body and in other keys do not count, which is what sets it apart fromfile.backlinks:file.linkedFrom("question").lengthcounts only the news notes whosequestionpoints at this question.
A note itself is a value too: file on its own is the note of the row, and asFile() gives the note a link points to. A note value takes every name above, so source.asFile().name and value.inFolder("Meetings") work. See Linked notes.
this
When a .base file is opened directly, this is that .base file. this.file gives its path, and this.file.name, this.file.basename, this.file.ext, this.file.path, this.file.folder, this.file.size, this.file.mtime and this.file.ctime give the same values as for a note (this.file.tags is an empty list). For example, file.inFolder(this.file.folder) keeps the notes next to the .base file, and file.links.contains(this.file) keeps the notes that link to it ([[Projects.base]] or [[P/Projects.base]]: a link to the .base file by its name or path gives the same value as this.file). Where there is no .base file to point at (a mdgrid view of a folder), an expression with this is not supported.
Linked notes
A formula can read values from the note a row links to (a lookup) and gather values from the notes that link to the row (a rollup). A reading note can show the author of its book, a book can count its reading notes, and a person can show the date of the last meeting they attended, without anyone copying the value by hand.
formulas:
# Reading notes: the author and kind of the book in `source`
author: 'source.asFile().properties.author'
kind: 'source.asFile().properties.kind'
# Books: how many reading notes cite this book in `source`
quotes: 'file.linkedFrom("source").length'
# People: the last meeting they attended that is done
met: 'file.linkedFrom("attendees").filter(value.inFolder("Meetings") && value.properties.status == "done").map(value.properties.when).max().date()'
.properties.<key> (or .properties["key"]) on a note value is that note’s frontmatter value, with pending (unsaved) values on top. When that value is a whole link, it becomes the note it points to, found from that note’s folder, so a lookup can go one more step: attendees[0].asFile().properties.org.properties.kind. The names of a note value also work straight on a link text, so source.properties.author is the same as source.asFile().properties.author. A note and a link text are compared by the note they point to: "[[Ana Lima]]" == file and value.properties.attendees.contains(file) both work.
On the screen, a note shows as its name (with display.note_name applied), a date in the date format of dates.format, and a value read with .properties.<key> with the value’s name from [rules.<key>] labels of the current table. --print writes a note as its path from the root folder without .md, the same as file.links.
Only notes under the table’s root folder can be looked up, the same ones file.links and file.backlinks see. A ledger whose tables are narrowed with [table.base] filters reaches every note of the ledger; a table opened on its own folder with path does not see the other folders. The links between notes come from the saved notes, so a link added in a pending value counts once it is saved. They sit in an index that mdgrid builds once per load, so a rollup reads only the notes that link to the row. One cell can use up to 200,000 steps; a formula that goes past that (deeply nested filter and map over long lists) shows the unsupported mark with the reason, and the other cells still show.
Summaries
A view’s summaries adds one row under the table, just above the bottom line. The left column says Summary (集計 in Japanese), and each summarized column shows the summary name and its value, for example Sum 18 or Earliest 2026-10-05, lined up with the column and scrolled with it. Summaries are computed from the rows the view shows now, after its filters, the view settings and the search, so narrowing the table changes the values. Pending (unsaved) values count. A view without summaries has no summary row. In Japanese the names are shown in Japanese (合計 18).
A view with groupBy also shows the summaries of each group, on the right of the group heading, lined up with the columns in the same way (▾ status: done (2) Sum 8). The heading text takes the room before the first summarized column (the note column grows a little, up to its usual limit, so that it fits). A folded group keeps its subtotals, so folding every group gives a list of the totals per group. The summary row under the table stays the total of the whole table. Numbers follow the column’s number format (Sum ¥101,500), except for the counting summaries.
To give a summary your own name, add summary_labels to the view. It is a key mdgrid adds, and Obsidian ignores it.
views:
- type: table
name: Open
summaries:
estimate: Sum
due: Earliest
done: Checked
summary_labels:
done: Done
The built-in summaries, as in Obsidian. Values of another type are not counted. When there is nothing to count, a number or date summary is blank; the counting summaries show 0.
| Name | Counts | Value |
|---|---|---|
Average | numbers | the mean |
Min | numbers | the smallest number |
Max | numbers | the largest number |
Sum | numbers | the sum |
Range | numbers, or dates | Max − Min; for a column of dates, Latest − Earliest as a duration |
Median | numbers | the middle number (the mean of the two middle numbers when the count is even) |
Stddev | numbers | the population standard deviation (divided by the count) |
Earliest | dates and date-times | the earliest |
Latest | dates and date-times | the latest |
Checked | booleans | the number of true |
Unchecked | booleans | the number of false |
Empty | any | the number of empty values (null, a missing key, an empty string, an empty list) |
Filled | any | the number of values that are not empty |
Unique | any | the number of different values that are not empty (the number 1 and the string "1" differ) |
Not supported
mdgrid does not evaluate the following. It never guesses a result for them.
- Every other function and method from Obsidian, for example
link(),icon(),image(), and methods such astoFixed(),repeat(),asLink(),linksTo(),keys(), andvalues(), and a regular expression given toreplace()orsplit(). Obsidian’s list may grow; anything not listed on this page is treated as unsupported. filepropertiesfile.embedsandfile.file,file.propertieson its own and with a method (file.properties.keys();file.properties.<key>works), and the functionlink().thisother thanthis.fileand its values listed under this, andthisfor a base embedded in a note (mdgrid only opens.basefiles).- Formula summaries: the top-level
summaries(for examplecustomAverage: 'values.mean()') and a view summary that names one, or any name that is not a built-in summary. The view still opens; the bottom line lists it afterunsupported:(未対応:in Japanese) and the other summaries are shown. - Views other than
table:cards,list,map, and plugin views. basecode blocks inside notes. mdgrid only opens.basefiles.
What you see when mdgrid meets one of these (the examples are the English messages; the Japanese screen says the same in Japanese):
- In
filters(top level or view): the view does not open. The table area shows the reason with the name, for example(this view cannot be opened: cannot evaluate the filters of view "Open": unsupported function or field .toFixed() (expression: price.toFixed(2) == "1.00")), and the bottom line says the view cannot be opened. Other views still open; switch with[]. - In a column (
formula.*orfile.*inorder): every cell of that column shows a dim?instead of a value and cannot be edited. The dim?is distinct from an empty cell (missing key) and from a real?value. Selecting such a cell shows the unsupported expression on the bottom line (so you can tell even when the terminal cannot draw dim text), and the column is listed afterunsupported:on the bottom line. - In
sortorgroupBy: the key is treated as empty for every row, and the bottom line notes that the view cannot be sorted by it. - A formula that refers to a missing formula or to itself in a loop counts as unsupported in the same way.
- A syntax error in an expression is reported the same way, with the reason instead of a name.