Skip to main content
cfo.ai formulas have 38 functions, listed here by category. Function names are not case-sensitive, so SUM and sum are the same function; write them in lowercase in new formulas. Each argument can be any expression, including a lookup, another function, or a condition. For operators, lookups, and filters, see Formula syntax. In the formula editor, press ⌥ F12 (Alt F12) to see the syntax and an example of the function under the cursor.

All functions at a glance

A call with the wrong number of arguments shows #VALUE! in its cells, and the editor names the limit, such as SUM requires between 1 and 10 arguments. A name that is not on this list shows #NAME?. See Formula errors and warnings.

Aggregation functions

Aggregation functions combine several values into one, such as every department’s revenue. The values usually come from a lookup that selects several items, such as Revenue[Department in any]. Empty values are skipped. Most take 1 to 10 arguments; median takes exactly one. For example, when Revenue is 50 for Sales, 30 for Marketing, and 20 for Engineering:

sum

sum adds numbers and always returns a number: a sum with no values returns 0.
It takes 1 to 10 arguments and adds the values of all of them: sum(Revenue[Region in any], `Other Income`[Region in any]).

product

product multiplies numbers. It returns 0 when there are no values.
It takes 1 to 10 arguments.

average

average returns the arithmetic mean of numbers, or an empty value when there are none. avg is an older name that still works.
It takes 1 to 10 arguments. With several arguments, it averages all their values together, so each value counts once.

min

min returns the smallest number, or an empty value when there are none.
It takes 1 to 10 arguments. With one argument that holds dates, it returns the earliest date; when values mix numbers and dates, the numbers decide. With several arguments, every argument must be a number.

max

max returns the largest number, or an empty value when there are none.
It takes 1 to 10 arguments. With one argument that holds dates, it returns the latest date, so the example returns the newest observation. When values mix numbers and dates, the numbers decide. With several arguments, every argument must be a number.

count

count returns how many values are not empty, of any type. It works like Excel’s COUNTA, not Excel’s COUNT.
It takes 1 to 10 arguments. A value of 0 counts.

first

first returns the first value that is not empty, in the order of the series, or an empty value when there is none.
Over an imported table’s rows, the order is the source’s date column. Rows on the same date keep the source’s order. A source with no date column is read in the source’s order. first takes several arguments only when each one is an imported column or a plain reference to a Variable or Dimension, with no arithmetic around it. It then returns the value from the input whose row is earliest. A dated row wins over an undated one, and when dates tie, the earlier argument wins.

last

last returns the last value that is not empty, in the order of the series, or an empty value when there is none. Use it for a balance or a headcount, where the period’s value is its latest one.
Over an imported table’s rows, last returns the row with the latest date in the source’s date column. Rows on the same date keep the source’s order. A source with no date column has no dates to compare, so last returns the last row in the source’s order. A reference to an imported column with no function around it reads the same way as last. last takes several arguments only when each one is an imported column or a plain reference to a Variable or Dimension, with no arithmetic around it. It then returns the value from the input whose row is latest. A dated row wins over an undated one, and when dates tie, the later argument wins. Each input keeps its own filters, so last(`Vendor A`, `Vendor B`) returns whichever vendor has the latest entry. This is how a Dimension combined from two accounting sources reads; see Dimension mappings and shared Dimensions.

median

median returns the middle number, or an empty value when there are none. With an even count of values, it returns the mean of the two middle ones.
It takes exactly one argument.

stdev

stdev returns the sample standard deviation, which divides by the count minus one. It returns an empty value when there are fewer than two values. stddev is an older name that still works.
It takes 1 to 10 arguments and pools all their values into one result.

var

var returns the sample variance, which divides by the count minus one. It returns an empty value when there are fewer than two values. variance is an older name that still works.
It takes 1 to 10 arguments and pools all their values into one result.

Math functions

abs

abs returns a number without its sign, so -5 becomes 5. An empty value stays empty.

sqrt

sqrt returns the square root of a number. Use it on zero or a positive number, and guard a value that can be negative.

ceiling

ceiling rounds a number up to the nearest multiple of a significance, as Excel’s CEILING does.
A positive number with a negative significance returns #NUM!.

floor

floor rounds a number down to the nearest multiple of a significance, as Excel’s FLOOR does.
A positive number with a negative significance returns #NUM!.

round

round rounds a number to a number of digits, as Excel’s ROUND does. A negative digit count rounds to the left of the decimal point.
The example rounds to the nearest thousand.

Conditional functions

if

if returns one value when a condition is true and another when it is false. It needs all three arguments; unlike Excel, the third one is not optional.
A condition that compares with an empty value is not true, so if returns the third argument. To test for an empty value, compare with null: if(`End Date` = null, 1, 0). You can nest calls: if(Revenue > 100, "high", if(Revenue > 50, "medium", "low")).

iferror

iferror returns a value, or a fallback when that value is an error such as a division by zero.
It takes exactly two arguments. An empty value is not an error, so iferror returns it unchanged.

Date-part functions

Date-part functions return one part of a date as a number. Each takes exactly one date, except weekday and weeknum.

year

year returns the four-digit year of a date, as Excel’s YEAR does.

month

month returns the month of a date as a number from 1 to 12.

day

day returns the day of the month as a number from 1 to 31.

quarter

quarter returns the calendar quarter of a date as a number from 1 to 4.

half

half returns 1 for a date from January to June and 2 for a date from July to December. It returns 2 when the date is empty.

weekday

weekday returns the day of the week as a number, as Excel’s WEEKDAY does. By default Sunday is 1 and Saturday is 7.
The optional return type sets the numbering: 1 (Sunday is 1, the default), 2 (Monday is 1), 3 (Monday is 0), or 11 to 17 (the week starts on Monday through Sunday).

weeknum

weeknum returns the week of the year, from 1 to 54, as Excel’s WEEKNUM does. Except with return type 21, week 1 is the week that contains January 1.
The optional return type sets the first day of the week: 1 (Sunday, the default), 2 (Monday), or 11 to 17 (Monday through Sunday). Return type 21 uses ISO 8601 weeks.

isoweeknum

isoweeknum returns the ISO 8601 week of the year, from 1 to 53. It is the same as weeknum(date, 21).

Date-truncation functions

Date-truncation functions return the first day of the period that contains a date. Each takes exactly one date. Use them to line up dates from a source with the Model’s periods.

startofday

startofday returns the start of the day that contains a date.

startofweek

startofweek returns the Monday that starts the week containing a date.

startofmonth

startofmonth returns the first day of the month containing a date.

startofquarter

startofquarter returns the first day of the calendar quarter containing a date.

startofhalf

startofhalf returns January 1 or July 1 of the half-year containing a date.

startofyear

startofyear returns January 1 of the year containing a date.

Date arithmetic and construction

dateadd

dateadd moves a date by a signed number of units.
The unit must be in quotes: "day", "week", "month", "quarter", "half", or "year". The amount is a whole number; a negative amount moves back.

datedif

datedif returns the whole number of units between a start date and an end date, as Excel’s DATEDIF does.
The unit is "Y", "M", "D", "MD", "YM", or "YD". The count leaves out the end day, so add 1 to count both ends. A start date after the end date returns #NUM!, and a value that is not a date returns #VALUE!.

daysin

daysin returns the number of days in the period that contains a date.
The unit is one of the dateadd units, in quotes. Use it to spread an amount by calendar days, such as `Annual Fee` / 365 * daysin(Date.Month, "month").

date

date builds a date from a year, a month, and a day, as Excel’s DATE does.
A month or day outside its range rolls into the next or previous month or year, so date(2026, 13, 1) is January 1, 2027. A year from 0 to 1899 has 1900 added. Unlike Excel, February 29, 1900 does not exist. A result outside the supported range returns #NUM!, and a value that is not a number returns #VALUE!.

edate

edate moves a date by whole months and keeps the day inside the new month, as Excel’s EDATE does.
A fraction of a month is dropped, so 2.7 moves two months.

eomonth

eomonth returns the last day of the month a signed number of months from a date, as Excel’s EOMONTH does.
Use 0 for the date’s own month, 1 for the next month, and -1 for the previous month. A fraction of a month is dropped.

Older names

These names still work in existing formulas. Write the preferred name in new ones.

Excel functions that are not available

cfo.ai has no function by these names. A formula that uses one shows #NAME?. Write the cfo.ai form instead.