Budgeting
You can look up what each function takes and returns, in which field KOSMA offers it, and what KOSMA shows when an argument does not exist.
A function calculates a figure for a formula. Function names are English in every interface language. To insert a function into a formula, see [write a formula](/kb/article/write-a-formula).
Put a name or an account number in quotes, for example `ACCOUNT("2.01")`.
| Function | Argument | Returns | | ----------------------- | --------------------------------------- | --------------------------------------------------------------------------------------------------------------- | | `ACCOUNT("2.01")` | an account number | the account's **Total**, in the budget's default currency | | `SUM_COMPANY("Name")` | a company | the company's share of the **Total** of every account and subaccount it is assigned to, except deactivated ones | | `COUNT_COMPANY("Name")` | a company | how many accounts and subaccounts the company is assigned to, except deactivated ones | | `SUM_TAG("Name")` | a tag | the full **Total** of every account and subaccount that carries the tag, except deactivated ones | | `COUNT_TAG("Name")` | a tag | how many accounts and subaccounts carry the tag, except deactivated ones | | `NPC` | none | the net production costs: the **Total** of all accounts that are not deactivated, without markups | | `GT` | none | the grand total: `NPC` plus the **Total** of all markups that are not deactivated | | `ACCOUNT_QTY` | none | the account's **Quantity** | | `SUBACCOUNT_QTY("2")` | the position of a subaccount, from 1 up | that subaccount's **Quantity** |
The company and tag functions count subaccounts and accounts that have no subaccounts. An account in a deactivated group counts as deactivated, and so do the subaccounts of a deactivated account. The row that holds the formula never counts toward its own result. For these functions, markups count only in the topsheet's **Info** widget, and only if they are not deactivated.
`ACCOUNT_QTY` and `SUBACCOUNT_QTY` work only in **Timebase (days) for fringe limits**. In this field you enter how many days a daily fringe limit applies to. KOSMA offers `SUBACCOUNT_QTY` there only when the account has subaccounts. If you type any other function there, KOSMA does not save it and shows:
Only ACCOUNT\_QTY and SUBACCOUNT\_QTY are allowed — '{the name}' is not.
For the steps, see [use quantities in formulas](/kb/article/use-quantities-in-formulas).
Each field offers its own list of functions. If you type a function the field does not offer, KOSMA marks it as an unknown part of the formula, even if the function works in another field. A formula copied from a markup into an account can therefore stop working, although the formula has not changed.
| Field | Functions | | ------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------ | | **Quantity**, **Price/Unit** and **X** of an account or subaccount | `ACCOUNT`, `SUM_COMPANY`, `COUNT_COMPANY`, `SUM_TAG`, `COUNT_TAG` | | **Base** of a markup | the five above and `NPC` | | **Calculation Formula** of a variable | the five above, `NPC` and `GT` | | **Info** widget of a topsheet, row set to **Formula** | the five above, `NPC`, `GT`, `SUM_EFFECT`, `FINANCING_CONFIRMED`, `FINANCING_SUBMITTED`, `FINANCING_PENDING` | | **Amount** of a financing plan | the five above, `NPC`, `GT`, `SUM_TAG_F`, `FINANCING_CONFIRMED`, `FINANCING_SUBMITTED`, `FINANCING_PENDING` | | **Timebase (days) for fringe limits** | `ACCOUNT_QTY`, `SUBACCOUNT_QTY`, and no variables | | the quantity and price of an extra cost, the factor of a wage supplement | no function. Variables except `GT`, and not `NPC` in the quantity of an extra cost |
`NPC` and `GT` also exist as variables, and the last row refers to those variables. The cells of an account and the **Base** of a markup do not offer `GT`. The grand total contains the markups, so the formula would depend on itself. You also cannot use a variable whose formula contains `NPC`, `GT`, `ACCOUNT`, `SUM_COMPANY` or `SUM_TAG` in the cells of an account. For the cells this covers, see [use variables in a budget](/kb/article/use-variables-in-a-budget). In the **Base** of a markup, such a variable works as long as its formula does not contain `GT`. For markup bases, see [use budget totals as a markup base](/kb/article/use-budget-totals-as-a-markup-base).
Six functions calculate from a financing plan. A financing plan's **Amount** offers four of them: all except `SUM_COMPANY_F` and `SUM_EFFECT`. KOSMA cannot calculate these two in a financing plan yet. The topsheet's **Info** widget offers all except `SUM_COMPANY_F` and `SUM_TAG_F`.
| Function | Argument | Returns | | ----------------------- | --------- | ---------------------------------------------------------------------------------------- | | `SUM_COMPANY_F("Name")` | a company | the sum of the **Amount** of every source of the company, in the plan's default currency | | `SUM_TAG_F("Name")` | a tag | the sum of the **Amount** of every source that carries the tag | | `SUM_EFFECT("Name")` | an effect | the sum of the **Amount** of every source that carries the effect | | `FINANCING_CONFIRMED()` | none | the sum of the **Amount** of every confirmed source | | `FINANCING_SUBMITTED()` | none | the sum of the **Amount** of every source that is submitted and not yet confirmed | | `FINANCING_PENDING()` | none | the sum of the **Amount** of every source with no status or another status |
The three status functions leave out deactivated sources and deactivated groups. In a financing plan, the functions calculate from that plan. In the **Info** widget, they calculate from the financing plan you selected in the topsheet. If none is selected, they calculate from wherever you opened the topsheet. If you opened it from a budget, the functions find no sources there, so select a financing plan in the topsheet.
`SUM_COMPANY` and `SUM_TAG` add up the budget. With the `_F` suffix, `SUM_COMPANY_F` and `SUM_TAG_F` add up the financing plan. If you use the name without the suffix in a financing plan's **Amount**, KOSMA returns the budget figure. To see totals per company, tag or effect in the budget, see [aggregate by company, tag or effect](/kb/article/aggregate-by-company-tag-or-effect).
Use `COUNT_COMPANY` and `COUNT_TAG` for a charge per line, for example per crew member. `SUM_TAG("Name") / COUNT_TAG("Name")` returns the average of those rows.
If an argument names something that does not exist, such as an account number the budget does not have, KOSMA marks the field with a red frame. When you hover over the frame, KOSMA shows:
Unknown part of expression
If you save such a formula in the budget, KOSMA keeps it with the red frame and shows:
Unknown Reference. The expression "{the unknown part}" refers to something that does not exist. Fix the formula to clear the error.
KOSMA shows the same two messages for every function. A company, tag or effect that exists but is assigned to nothing returns `0`. If a row's **Total** is empty, `SUM_COMPANY`, `SUM_TAG`, `NPC` and `GT` skip that row and add up the rest. `ACCOUNT` returns no value at all for an account with an empty **Total**, not even `0`.
A formula cannot make a total depend on itself, directly, through a variable or through other formulas. KOSMA does not save such a formula. When the formula makes an account's total depend on itself, KOSMA shows:
This formula would make the account's total depend on itself, which creates a circular reference.
For any other circular reference, KOSMA shows:
This formula creates a circular reference, so the change could not be saved.
In the **Quantity**, **Price/Unit** and **X** cells of the budget, KOSMA greys out every account, company or tag in the function's list that would create a circular reference. When you hover over a greyed-out entry, KOSMA shows:
Using this would create a circular reference
In every other field, KOSMA reports the circular reference only when you save the formula.
KOSMA renamed two functions: `SUM_PROD` is now `SUM_COMPANY`, and `COUNT_PROD` is now `COUNT_COMPANY`. A formula that still uses an old name shows the red frame. Replace the name in the formula. The argument and the result stay the same.
Markdown