Excel Custom Functions
The Konsolidat Excel add-in registers 8 functions in the K namespace: K.PING, K.EPM, K.EPM_BUDGET, K.EPM_VARIANCE, K.EPM_DEBIT, K.EPM_CREDIT, K.CF and K.EPMSAVE. They are Office.js custom functions. Excel calculates them like any other formula, and the add-in sends the read calls to the server in batches.
Source of truth: konsol/public/excel-addin/ in the konsol repository. functions.json declares the functions and their parameters; functions.js implements them. Frappe serves both at /assets/konsol/excel-addin/. This page follows those two files as they are on 2026-11-07 (manifest version 2.0.2.0). The docs drift check fails if a signature on this page lists different parameters from functions.json.
The add-in works in Excel for Windows, Excel for Mac and Excel on the web. Sign in through the task pane first (see Excel Task Pane Guide).
The K namespace
The manifest sets the namespace to K (Functions.Namespace in the manifest). Every function is called with the K. prefix:
=K.PING()
=K.EPM("USMF", 2024, 1, "401100")
=K.EPM_BUDGET("USMF", 2024, "Q1", "401100")
=K.CF("GROUP_CORP", 2024, 6, "Change in Inventory")
=K.EPMSAVE(50000, "USMF", 2024, 1, "401100", "SC-2024", "base")
A cell that shows #NAME? means Excel has not registered the K. functions. See Errors.
Function list
| Function | Does | Server call |
|---|---|---|
K.PING | Returns 1. Confirms the functions are registered. | none |
K.EPM | Reads one value: actuals by default, any measure and scenario on request | konsol.api.epm_batch |
K.EPM_BUDGET | Reads a budget amount (measure=period_amount, scenario=budget) | konsol.api.epm_batch |
K.EPM_VARIANCE | Reads an absolute variance (measure=variance_abs, scenario=variance) | konsol.api.epm_batch |
K.EPM_DEBIT | Reads period debit (measure=period_debit, scenario=actuals) | konsol.api.epm_batch |
K.EPM_CREDIT | Reads period credit (measure=period_credit, scenario=actuals) | konsol.api.epm_batch |
K.CF | Reads one consolidated cash-flow line for a group | konsol.api.epm_batch |
K.EPMSAVE | Writes one budget cell | konsol.api.budget_cell_save |
All results are numbers. Parameter names below are the names in functions.json. Square brackets mark optional parameters. To skip an optional argument and give a later one, leave its slot empty (, ,).
K.PING
=K.PING()
Returns 1 without calling the server. The task pane uses it to test that Excel has registered the K. functions. If this cell shows #NAME?, the add-in is not loaded or Excel could not fetch functions.json.
K.EPM — general read
=K.EPM(entity, year, period, account, [measure], [scenario], [dimensions], [scenarioId], [hierarchy], [node], [layer])
| Parameter | Type | Required | Description (from functions.json) |
|---|---|---|---|
entity | string | yes | Legal entity / data area id. ALL for a cross-entity hierarchy rollup |
year | number | yes | Fiscal year, e.g. 2024 |
period | string | yes | 1–12, or Q1–Q4, H1–H2, FY. See Periods |
account | string | yes | Main account code |
measure | string | no | Measure. Blank uses the Dataset's own default measure |
scenario | string | no | Scenario. Blank means actuals |
dimensions | text or range | no | Dimension filters: one text cell such as "dim_region=EU;dim_product=X", or a 2-column range of name/value rows. See Dimensions |
scenarioId | string | no | Explicit scenario id (budget or forecast) |
hierarchy | string | no | Reporting hierarchy name. May be blank only when the node is in exactly one published hierarchy |
node | string | no | Hierarchy member code. Setting it turns on hierarchy mode |
layer | string | no | Budget layer (base, challenge, management, board). Only budget facts use it. Blank sums all layers (the final budget) |
What functions.js sends: entity, year, period, account always; each optional parameter only when it is not blank. The server fills the blanks: a blank measure becomes the Dataset's declared default measure (_measure_for in konsol/api.py); a blank scenario becomes actuals. A Dataset with no default measure refuses a read that names none, and the error lists the measures it has.
Hierarchy mode: when node is set, the server reads the hierarchy gold tables instead of the flat entity fact and sums every leaf under the node. If the node code is in more than one published hierarchy and hierarchy is blank, the cell shows #VALUE! with a message that names the hierarchies. A hierarchy without a node is refused.
Examples:
=K.EPM("USMF", 2024, 5, "401100")
=K.EPM("USMF", 2024, "Q1", "401100", "ytd_net_amount")
=K.EPM("USMF", 2024, "FY", "401100", "", "actuals", "dim_region=EU")
=K.EPM("USMF", 2025, 5, "6100", "period_amount", "budget", "", "BUDGET_2025")
=K.EPM("ALL", 2026, "FY", "400000", "", "", "", "", "MGMT_2026", "DACH")
K.EPM_BUDGET
=K.EPM_BUDGET(entity, year, period, account, [dimensions], [scenarioId], [hierarchy], [node], [layer])
Same as K.EPM with measure=period_amount and scenario=budget fixed. Blank layer returns the final budget (sum of all layers); a layer name returns that layer only.
K.EPM_VARIANCE
=K.EPM_VARIANCE(entity, year, period, account, [dimensions], [scenarioId], [hierarchy], [node])
Same as K.EPM with measure=variance_abs and scenario=variance fixed. No layer.
K.EPM_DEBIT
=K.EPM_DEBIT(entity, year, period, account, [dimensions], [hierarchy], [node])
Same as K.EPM with measure=period_debit and scenario=actuals fixed. No scenarioId, no layer.
K.EPM_CREDIT
=K.EPM_CREDIT(entity, year, period, account, [dimensions], [hierarchy], [node])
Same as K.EPM with measure=period_credit and scenario=actuals fixed. No scenarioId, no layer.
K.CF — consolidated cash flow
=K.CF(group, year, period, line)
| Parameter | Type | Required | Description |
|---|---|---|---|
group | string | yes | Consolidation group, e.g. GROUP_CORP |
year | number | yes | Fiscal year |
period | string | yes | 1–12, or Q1–Q4, H1–H2, FY |
line | string | yes | Cash-flow line name, e.g. Change in Inventory or Net Income (Consolidated) |
K.CF uses the same epm_batch request as K.EPM, pointed at the cashflow Dataset (gold_cashflow_fact): the group goes in the entity field, the line name in the account field, with measure=cash_flow_amount and fact=cashflow. It has no dimension, hierarchy or layer parameters.
=K.CF("GROUP_CORP", 2024, 6, "Change in Inventory")
K.EPMSAVE — budget write
=K.EPMSAVE(amount, entity, year, period, account, scenarioId, layer, [dimensions], [hierarchy], [node])
| Parameter | Type | Required | Description |
|---|---|---|---|
amount | number | yes | Value to write |
entity | string | yes | Legal entity / data area id |
year | number | yes | Fiscal year |
period | number | yes | Fiscal period 1–12. One period per cell; no ranges |
account | string | yes | Main account code |
scenarioId | string | yes | Scenario id, e.g. BUDGET_2025 |
layer | string | yes | base, challenge, management or board |
dimensions | text or range | no | The budget line's dimensions, in the same form as for K.EPM. A name that is not one of the site's budget dimensions is refused |
hierarchy | string | no | Reporting hierarchy name |
node | string | no | Hierarchy leaf member code. Writes at that leaf |
The cell shows amount once the server has saved it:
functions.jschecks thatamount,yearandperiodare numbers. If not, the cell shows#VALUE!with the textInvalid EPMSAVE arguments. A malformeddimensionsargument shows#VALUE!(see Dimensions).- It builds a key from every parameter and compares
amountwith the last value it saved for that key. If equal, it returnsamountand sends nothing. This stops a recalculation from re-saving every budget cell. - Otherwise it posts to
konsol.api.budget_cell_savewithscenario_id,data_area_id,fiscal_year,main_account,fiscal_period,amount,layer, and, when given,dimensions(an object of name to value),hierarchyandhierarchy_node. - The server writes the period into the Budget Line for that account (and dimensions) on the Budget Sheet for (Budget Cycle × entity × layer). It creates the sheet, and an Open Budget Cycle for (scenario, year), when they do not exist. Before writing it checks your access to the entity, the account and the dimensions (
_assert_budget_write_access); the layer is data, not a permission. - On success the add-in remembers the value and the cell shows
amount.
If the server refuses the write, the cell shows #N/A. Nothing is remembered, so the next recalculation tries again. The server refuses a write when the Budget Cycle is locked (HTTP 423, "the budget is final"), when the layer is not one of the four, when the period is outside 1–12, when a dimension name is not a budget dimension, or when you lack write access to that entity, account or dimension. For each of these the cell shows the server's reason, except a missing write access: the server answers it with HTTP 403, which the add-in shows as Not logged in — open the Konsolidat task pane and sign in. If you are signed in and still see that text on a K.EPMSAVE cell, check your write access in Frappe Desk (konsol#423). Before konsol#287 a refused write still showed the amount.
Budget data reaches ClickHouse, and so K.EPM_BUDGET, when the Budget Cycle is locked. See the Budget Layers Guide.
Examples:
=K.EPMSAVE(100000, "USMF", 2025, 1, "6100", "BUDGET_2025", "base")
=K.EPMSAVE(-5000, "USMF", 2025, 1, "6100", "BUDGET_2025", "challenge")
=K.EPMSAVE(B5, "USMF", 2025, 1, "6100", "BUDGET_2025", "base", "dim_region=EU")
=K.EPMSAVE(B5, $A$1, $A$2, C$3, $A5, $A$4, "base")
Dimensions
dimensions is one argument for any number of dimensions (konsol#287). Every read function except K.CF takes it, and so does K.EPMSAVE. Give it in one of two forms:
- One text cell:
"dim_region=EU;dim_product=X". Spaces around names and values are ignored. This form cannot carry a value that contains;. Use the range form for such a value. - A 2-column range: names in the first column, values in the second, for example
$H$1:$I$2holdingdim_region | EUanddim_product | X. The range has no header row: every row is a name/value pair. A fully blank row is skipped.
Each name is a dimension your site declared (a Published Dimension record). No dimension is shipped; the examples on this page use dim_region and dim_product. The server refuses a name the Dataset does not have (reads) or that is not a budget dimension (K.EPMSAVE).
The add-in refuses a malformed argument before it sends anything: a pair without =, a name without a value, a value without a name, a name given twice, or a range that is not 2 columns wide. The cell shows #VALUE! with the reason. The add-in never drops a malformed filter, because a dropped filter would return the total over every value of that dimension.
Rewriting formulas from before konsol#287
The functions used to take two fixed arguments, cost centre and department, where dimensions now is. Every later argument moved one place to the left. A formula breaks if it passes either fixed argument or any later argument. Formulas with only the required arguments (and, for K.EPM, measure and scenario) are unchanged.
| Before | After |
|---|---|
=K.EPM("E1",2026,3,"4000","","","EU","X") | =K.EPM("E1",2026,3,"4000","","","dim_region=EU;dim_product=X") |
=K.EPM("E1",2026,3,"4000","","","","","","H1","N1") | =K.EPM("E1",2026,3,"4000","","","","","H1","N1") |
=K.EPM_BUDGET("E1",2026,3,"6100","","","PLAN26") | =K.EPM_BUDGET("E1",2026,3,"6100","","PLAN26") |
=K.EPM_VARIANCE("E1",2026,"FY","6100","EU","X") | =K.EPM_VARIANCE("E1",2026,"FY","6100","dim_region=EU;dim_product=X") |
=K.EPM_DEBIT("E1",2026,3,"1300","","","H1","N1") | =K.EPM_DEBIT("E1",2026,3,"1300","","H1","N1") |
=K.EPMSAVE(B5,"E1",2026,1,"6100","PLAN26","base","EU") | =K.EPMSAVE(B5,"E1",2026,1,"6100","PLAN26","base","dim_region=EU") |
=K.EPMSAVE(B5,"E1",2026,1,"6100","PLAN26","base","","","H1","N1") | =K.EPMSAVE(B5,"E1",2026,1,"6100","PLAN26","base","","H1","N1") |
The rule: where the old formula had two slots for cost centre and department, the new one has one slot. Put both values in it as name=value pairs, or leave it empty. Then copy the remaining arguments unchanged. Each name is the one your site declared for the dimension the old argument filtered on.
A formula left unrewritten shows an error, not a wrong number. Each old value lands one slot to the left, and at least one landing in every such formula is refused:
- a bare value such as
"EU"indimensionsis notname=value; - an old department value in
scenarioIdis refused when the Dataset has no scenario column (actuals), and when it names no Scenario (budget); - an old scenario id in
hierarchyis refused because it has no node; - an old last argument (
layer,node) is one argument too many, and the add-in refuses a formula with more arguments than the signature:K.EPM takes at most 11 arguments, but argument 12 is ….
Two consequences of these refusals:
- A hierarchy needs a node on every row. A sheet that fixes the hierarchy and leaves
nodeblank on some rows shows an error on those rows. Before, the hierarchy was ignored there. Leavehierarchyblank on rows that read no node. - A scenario id must exist and must have a column to filter. A
scenarioIdon actuals, or one that names no Scenario, is refused, not ignored or read as 0.
A workbook still on the old add-in sends the old request keys. The server refuses those rows ("Unknown request key"), so reload the add-in.
Workbooks from the retired VBA module
The VBA module excel/OpenEPM.bas was retired on 2026-09-12 (konsolidat#163, konsol#153). The add-in is the only Excel client. The VBA functions had no K. prefix. To convert such a workbook, use Find and Replace to change EPM( to K.EPM( and the other function names in the same way, rewrite any dimension arguments as in the table above, and save the workbook as .xlsx.
Periods
functions.json documents period as 1–12, Q1–Q4, H1–H2 or FY. The server resolves the token against the fiscal calendar declared for that year (resolve_period in konsol/period_read_model.py), so it also accepts the year's declared period codes, for example P07, 13 or CLS for the closing period and 0 or OPN for the opening period. FY is the sum of the regular periods. A token the calendar does not declare fails that one cell with a message that lists the declared set (konsol#251).
K.EPMSAVE takes a single period 1–12 only.
Periods with no trial balance
An actuals read of a period that has no trial balance shows #N/A with a message such as No trial balance for USMF 2024 P5 (konsol#401). Before, it showed 0. A loaded period where the account has no balance still shows 0.
- A range such as
Q1orFYreads if at least one of its periods is loaded. - A read across all entities (hierarchy mode with the entity blank or
*) is refused only when no entity you may read has a trial balance for the period. - Budget reads are not checked: no budget is budget zero.
Batching
Every read function puts its request in a queue and schedules one flush at the end of the current JavaScript tick (enqueue and flush in functions.js). All cells Excel calculates in the same pass go out together as one POST /api/method/konsol.api.epm_batch. A flush larger than MAX_BATCH = 2000 requests is split into chunks of 2000, one request each; the server refuses a larger batch (MAX_BATCH_SIZE = 2000 in konsol/api.py).
The server answers { values: [...] } in request order, with errors and error_codes lists beside it when a row failed. Each cell gets its own value or its own error. An error whose code is no_data shows as #N/A; any other error shows as #VALUE!. A null value shows as 0. One bad cell does not fail its neighbours.
A year that is not a number fails in the add-in before anything is sent: the cell shows #VALUE! with the text Invalid year.
Errors
| Cell shows | Text | Cause |
|---|---|---|
#NAME? | — | Excel has not registered the K. functions: the add-in is not loaded, or Excel on the web could not fetch functions.json. Open the task pane; its Messages panel reports names=no |
#N/A | Not logged in — open the Konsolidat task pane and sign in. | The server answered 401 or 403. Sign in through the task pane |
#N/A | No trial balance for <entity> <year> <period> | An actuals read of a period with no trial balance. See Periods with no trial balance |
#N/A | server message, or Request failed (HTTP <status>) | Any other non-2xx answer, including a refused K.EPMSAVE write |
#VALUE! | Invalid year | year is not a number (checked in the add-in) |
#VALUE! | dimensions: … | A malformed dimensions argument (checked in the add-in) |
#VALUE! | K.<name> takes at most <n> arguments, … | More arguments than the signature: a formula from before konsol#287 |
#VALUE! | server message | The server refused that row: unknown scenario, measure or dimension for the Dataset, an unknown request key, a hierarchy without a node, a period the calendar does not declare, an entity you may not read, a node in several hierarchies |
#VALUE! | Invalid EPMSAVE arguments | amount, year or period of K.EPMSAVE is not a number |
0 | — | A loaded period with no balance on that account, a budget with no amount, or the server returned null |
Office.js maps the add-in's notAvailable error to #N/A and invalidValue to #VALUE!. Server messages are passed through as written, for example Invalid measure 'x' for fact 'gold_trial_balance'. Allowed: ....
Recalculating
The Refresh sheet and Refresh workbook buttons on the Home ribbon recalculate the K. formulas, take saved snapshots again, and stamp each refreshed sheet with Values as of <YYYY-MM-DD HH:MM> UTC from <site host> in row 1. See Ribbon: Refresh sheet and Refresh workbook.
Authentication
The task pane signs in with konsol.api.excel_addin_auth and stores the returned token in localStorage under konsol_token:<site origin>, one per site. Every request from functions.js sends that token in the X-Konsolidat-Token header. With a token it sends no cookies (credentials: "omit"): a Desk session in the same browser carries a CSRF token, and Frappe refuses a POST without it. Without a token it sends cookies. On the server, konsol.excel_addin_auth.apply_excel_token_auth runs before every request and signs the request in as the token's user when the session is otherwise Guest. A token is valid for 8 hours.
The functions see the token because the manifest declares a shared runtime (SharedRuntime requirement, <Runtime lifetime="long">): one browser runtime hosts the task pane and the functions, so they share localStorage and the workbook's settings, where the workbook's chosen server is kept. Until you sign in, read cells and K.EPMSAVE cells show #N/A, usually with the "Not logged in" text.
The manifest
konsol no longer ships a static manifest (konsol#605). Each site serves its own, built from its host_name: download it from Close Settings → Excel Add-in → Download Excel add-in, or from /api/method/konsol.excel_addin.manifest on the site. Every URL in it (SourceLocation, Functions.Metadata.Url, the icons, SupportUrl, AppDomains) is that site's, so nothing needs editing. The Id is derived from the site's address, and the Version is 2.0.6.0. A user who installed an older static manifest.xml removes it and installs the downloaded file; a later version change needs the same reinstall.
Next steps
- Excel Task Pane Guide — install, sign in, Apply report, Snapshot, the ribbon refresh buttons, Messages
- Budget Layers Guide — how the four layers add up and when they reach ClickHouse
- Budgeting Guide — budget reads with
K.EPM_BUDGET