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 asRevenue[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.
sum(Revenue[Region in any], `Other Income`[Region in any]).
product
product multiplies numbers. It returns 0 when there are no values.
average
average returns the arithmetic mean of numbers, or an empty value when there are none. avg is an older name that still works.
min
min returns the smallest number, or an empty value when there are none.
max
max returns the largest number, or an empty value when there are none.
count
count returns how many values are not empty, of any type. It works like Excel’s COUNTA, not Excel’s COUNT.
first
first returns the first value that is not empty, in the order of the series, or an empty value when there is none.
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.
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.
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.
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.
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.
#NUM!.
floor
floor rounds a number down to the nearest multiple of a significance, as Excel’s FLOOR does.
#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.
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.
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.
iferror returns it unchanged.
Date-part functions
Date-part functions return one part of a date as a number. Each takes exactly one date, exceptweekday 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.
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.
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.
"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.
"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.
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.
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.
eomonth
eomonth returns the last day of the month a signed number of months from a date, as Excel’s EOMONTH does.
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.