Skip to content

Formula recipes ​

Ready-made formulas for the things people ask for most. You don't need to know JavaScript: copy the formula, then replace each field token with your own field (select the token, then click your field in the Fields list). The Type under each recipe is the column type to pick.

New to formulas? Read Formula basics first, especially How each column type arrives.

Excel data sources

The date recipes use DateTime.fromISO(...), which suits SharePoint lists. For dates from an Excel data source, use DateTime.fromJSDate(...) instead.

Dates ​

Days until a date ​

Whole days from today until the date: tomorrow is 1, yesterday is -1. Like Excel's =A2-TODAY().

js
{[EndDate]} ? Math.round(DateTime.fromISO({[EndDate]}).startOf('day').diff(DateTime.now().startOf('day'), 'days').days) : null

Type: Number. An empty date gives an empty value.

Days since a date ​

Whole days from the date until today. Like Excel's =TODAY()-A2.

js
{[Created]} ? Math.round(DateTime.now().startOf('day').diff(DateTime.fromISO({[Created]}).startOf('day'), 'days').days) : null

Type: Number.

Overdue label ​

'Overdue' when the due date is before today and the item isn't finished.

js
{[DueDate]} != null && DateTime.fromISO({[DueDate]}) < DateTime.now().startOf('day') && {[Status]} !== 'Done' ? 'Overdue' : 'On track'

Type: Single Line of Text. Replace 'Done' with your own "finished" status. For a Yes/No column, leave out ? 'Overdue' : 'On track' and pick Yes/No.

Age or years of service ​

Like Excel's =DATEDIF(A2, TODAY(), "y").

js
{[StartDate]} ? Math.floor(DateTime.now().diff(DateTime.fromISO({[StartDate]}), 'years').years) : null

Type: Number. Use 'months' and .months for whole months.

Month, quarter and week labels for charts ​

js
DateTime.fromISO({[Created]}).toFormat('yyyy-MM')        // 2026-03
DateTime.fromISO({[Created]}).toFormat("yyyy 'Q'q")      // 2026 Q1
DateTime.fromISO({[Created]}).toFormat("kkkk-'W'WW")     // 2026-W11 (ISO week)
DateTime.fromISO({[Created]}).toFormat('yyyy')           // 2026

Type: Single Line of Text. These sort in date order. A month name ('MMMM', 'March') sorts alphabetically, so put the year and month number first when the label goes on a chart axis.

Add days to a date ​

js
{[InvoiceDate]} ? DateTime.fromISO({[InvoiceDate]}).plus({ days: 30 }).toISO() : null

Type: Date and Time. Use months, weeks or years instead of days as needed.

Working days between two dates ​

Monday to Friday, counting both the start and end date, like Excel's NETWORKDAYS without holidays.

js
if (!{[StartDate]} || !{[EndDate]}) return null;
let day = DateTime.fromISO({[StartDate]}).startOf('day');
const end = DateTime.fromISO({[EndDate]}).startOf('day');
let count = 0;
while (day <= end) {
    if (day.weekday <= 5) count++;
    day = day.plus({ days: 1 });
}
return count;

Type: Number. This is a multi-line formula: paste all of it.

People and lookups ​

Person's name, with a default ​

A Person field already holds the person's display name.

js
{[AssignedTo]} || 'Unassigned'

Type: Single Line of Text.

Person's email ​

js
{[AssignedTo_UserDetails]}?.email ?? ''

Type: Single Line of Text. AssignedTo is the column's internal name. The _UserDetails field isn't in the Fields list, so type it yourself; the editor warns that it isn't in the data source, which you can ignore.

Number of people in a multi-person field ​

js
({[Team]} ?? []).length

Type: Number. To list them as text instead: ({[Team]} ?? []).join(', ').

Lookup value and lookup ID ​

A lookup field already holds the value it shows, so {[Project]} on its own is the project's title. For the ID of the looked-up item:

js
{[Project_RawLookupValue]}?.lookupId ?? null

Type: Number.

Yes/No and choices ​

Yes/No as a label ​

Yes/No fields are true or false, not the text 'Yes'.

js
{[IsActive]} ? 'Active' : 'Inactive'

Type: Single Line of Text.

Count the selected choices ​

js
({[Tags]} ?? []).length

Type: Number.

Does a multi-choice field contain a value? ​

js
({[Tags]} ?? []).includes('Urgent')

Type: Yes/No. Upper and lower case must match the choice exactly.

Numbers and text ​

Multiply, keeping empty values empty ​

An empty number counts as 0 in arithmetic, so {[Quantity]} * {[UnitPrice]} gives 0 when Quantity is empty. To leave the result empty instead:

js
{[Quantity]} == null || {[UnitPrice]} == null ? null : {[Quantity]} * {[UnitPrice]}

Type: Number.

Value bands ​

js
{[Total]} < 1000 ? 'Small' : {[Total]} < 10000 ? 'Medium' : 'Large'

Type: Single Line of Text. Add more : {[Total]} < ... ? '...' steps for more bands; the first match wins.

Currency or thousands separators ​

Keep the column as a Number when you can, and set decimals and formatting in the widget, so it still sorts and totals as a number. When you need the text itself, for example in a label:

js
{[Amount]} == null ? '' : '€' + {[Amount]}.toLocaleString('en-IE', { minimumFractionDigits: 2, maximumFractionDigits: 2 })

Type: Single Line of Text. Gives €12,345.60. Change '€' and 'en-IE' to suit, for example '$' and 'en-US'.

Round to two decimals ​

js
Math.round({[Value]} * 100) / 100

Type: Number. Like Excel's =ROUND(A2, 2).

Full name when one part may be empty ​

js
[{[FirstName]}, {[LastName]}].filter(Boolean).join(' ')

Type: Single Line of Text. Avoids a leading or trailing space when one name is missing.

Initials and first word ​

js
[{[FirstName]}, {[LastName]}].filter(Boolean).map((name) => name[0]).join('')  // AB
({[Title]} || '').split(' ')[0]                                              // first word

Type: Single Line of Text.

A fallback when the formula might fail ​

Like Excel's =IFERROR(..., 0).

js
try {
    return {[Used]} / {[Budget]} * 100;
} catch (error) {
    return 0;
}

Type: Number. Dividing by zero doesn't fail in a formula, it gives Infinity, so guard division with a check instead: {[Budget]} ? {[Used]} / {[Budget]} * 100 : 0.

Aggregated fields ​

These go in an aggregated field (the Σ button), which produces one value for the whole data source, for example for a Summary Card.

Count rows that match a condition ​

js
CountIf({[Status]}, 'Open')                       // Status is exactly Open
CountIf({[Status]}, (s) => s !== 'Done')          // Status is anything but Done
CountIf({[Amount]}, (v) => v > 1000)              // Amount over 1000

For a condition on several fields, make a dynamic column first and count it. With the Overdue label as a Yes/No column called Is overdue:

js
CountIf({[Is overdue]}, true)

Percentage of rows that match ​

js
data.length > 0 ? Math.round(CountIf({[Status]}, 'Won') / data.length * 100) : 0

Type: Number. data.length is the number of rows.

Count of rows this month, or in the last 30 days ​

js
CountIf({[CloseDate]}, (d) => d != null && DateTime.fromISO(d).hasSame(DateTime.now(), 'month'))
CountIf({[Created]}, (d) => d != null && DateTime.fromISO(d) >= DateTime.now().minus({ days: 30 }))

Type: Number. Use 'year' or 'week' instead of 'month' for this year or this week.

Total for one value, or for two conditions ​

js
SumIf({[Revenue]}, {[Region]}, 'North')

data.filter((row) => row.Region === 'North' && row.Status === 'Won')
    .reduce((total, row) => total + (row.Revenue ?? 0), 0)

Inside data, fields are read by internal name (row.Region), see When you need row-level conditions.

Average, leaving out zeros ​

js
AverageIf({[Score]}, {[Score]}, (v) => v !== 0)

Earliest and latest date ​

js
Min({[Created]})
Max({[Created]})

Type: Date and Time. Use Min and Max rather than First and Last, which follow the row order, not the dates.

Ratio of two totals ​

js
Sum({[Budget]}) > 0 ? Math.round(Sum({[Spent]}) / Sum({[Budget]}) * 1000) / 10 : 0

Type: Number. Gives a percentage with one decimal, for example 87.5.

KPIs and dashboard filters

An aggregated field is calculated over the rows the data source loads. To make it follow a dashboard filter, see Filters.

Missing a recipe? ​

Email info@sintelapps.com with what you're trying to calculate, and we'll add it here.