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 | | `COUNT_COMPANY("Name")` | a company | how many accounts and subaccounts the company is assigned to | | `SUM_TAG("Name")` | a tag | the full **Total** of every account and subaccount that carries the tag | | `COUNT_TAG("Name")` | a tag | how many accounts and subaccounts carry the tag | | `NPC` | none | the net production costs: the **Total** of all accounts, without markups | | `GT` | none | the grand total: `NPC` plus the **Total** of all markups | | `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 with subaccounts counts through its subaccounts. The row that holds the formula never counts toward its own result. Markups count only in the **Info** widget of a topsheet.
`ACCOUNT_QTY` and `SUBACCOUNT_QTY` work only in **Timebase (days) for fringe limits**, the field for the number of days on which daily fringe limits are calculated. KOSMA offers `SUBACCOUNT_QTY` there only when the account has subaccounts. If you type any other name 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_COMPANY_F`, `SUM_TAG_F`, `SUM_EFFECT`, `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, but not `GT`, and not `NPC` in the quantity of an extra cost |
No field in a budget offers `GT`, because the grand total contains the markups. You cannot use a variable whose formula uses `NPC`, `GT`, `ACCOUNT`, `SUM_COMPANY` or `SUM_TAG` in an account, a subaccount, an extra cost quantity or the factor of a wage supplement. KOSMA does not accept the entry. In the **Base** of a markup, such a variable works if its formula does not use `GT`. For markup bases, see [use budget totals as a markup base](/kb/article/use-budget-totals-as-a-markup-base).
Six functions read a financing plan. A financing plan's **Amount** offers all six. The **Info** widget of a topsheet 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 | | | `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 read that plan. In the **Info** widget, they read the financing plan selected in the topsheet. If none is selected, they read the dataset in which you opened the topsheet.
The `_F` suffix marks the difference. `SUM_COMPANY` and `SUM_TAG` add up the budget, and `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 point at the frame, KOSMA shows:
Unknown part of expression
When you save such a formula in the budget, KOSMA shows:
Unknown Reference. The expression "{the unknown part}" refers to something that no longer exists. 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`. `SUM_COMPANY`, `SUM_TAG`, `NPC` and `GT` add up the rows that have a total and leave out rows without one. Only `ACCOUNT` returns no value if its account has no total.
A formula cannot make a total depend on itself, directly, through a variable or through other formulas. KOSMA does not save such a formula and shows one of these messages:
This formula would make the account's total depend on itself, which creates a circular reference.
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 point at 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