> For the complete documentation index, see [llms.txt](https://docs.phocassoftware.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.phocassoftware.com/financial-statements/managing-statements/customize-a-financial-statement/customize-calculations/functions-for-profit-and-loss-calculations.md).

# Functions for Profit & Loss calculations

Learn about the inbuilt functions you can use in the Profit and Loss statement calculations.

See also Formulas for financial ratios.

## \[acc] <a href="#functionsforprofitandlosscalculations-acc" id="functionsforprofitandlosscalculations-acc"></a>

{% hint style="success" %}
Watch this PUG Training video: [Cashflow - direct and indirect](https://www.phocassoftware.com/customer/training-series/financial-statements#session4) (jump to 23.00)
{% endhint %}

The Account \[acc] function references a single account code, allowing you to insert the values of an account, rather than a group, into a financial statement. This function respects the values as displayed on the statement. For example, if the **Reverse Sign** option is applied to a Revenue group to present values as positive, a referenced Revenue account will also be positive.

You can only reference accounts that are in the underlying financial statement.

Click **fx** in the formula bar, then select **Profit and loss accounts (acc)** from the list (this reads **Balance sheet accounts (acc)** if you're building the calculation in a Balance Sheet). Use the **Filter by code or keyword** search box to find the account, then select it from the list to insert it into your formula.

<details>

<summary>Example: Exclude an account from the marketing expenses group in a Profit and Loss statement</summary>

Suppose you want to display the value of the Marketing Expense excluding the Digital Marketing (account code 6530) in the Profit and Loss statement. Add a calculation row with a reference to the Marketing Expense row less the new function referencing the Digital Marketing account code.

<figure><img src="https://3180484653-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKhoFIsurMPEjkuBz9YkN%2Fuploads%2FdLJMjD0JvrjvgE6GyZtI%2Fimage.png?alt=media&amp;token=62e4e8f5-b062-49ef-8327-ad9e2fa35b3b" alt=""><figcaption></figcaption></figure>

</details>

## \[bal] <a href="#functionsforprofitandlosscalculations-bal" id="functionsforprofitandlosscalculations-bal"></a>

{% hint style="success" %}
Watch these PUG Training videos: [Ratios and statistical streams](https://www.phocassoftware.com/customer/training-series/financial-statements#session3) (jump to 03.29) and [Cashflow - direct and indirect](https://www.phocassoftware.com/customer/training-series/financial-statements#session4) (jump to 23.00)
{% endhint %}

The Balance \[bal] function references the Balance Sheet, allowing you to select Balance Sheet entities to include in calculations on the Profit and Loss statement, which is useful for calculating financial ratios.

Click **fx** in the formula bar, then select **Balance sheet (bal)**. Expand the Balance Sheet tree and click the account group you want (for example, **Intangible Assets**) to reveal its **average**, **closing**, and **movement** options, then select the one you need.

<div align="left"><figure><img src="https://3180484653-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKhoFIsurMPEjkuBz9YkN%2Fuploads%2Fh4K2ZwJMYn7QxkbK3tTC%2Fimage.png?alt=media&amp;token=ac732584-dabf-4abe-b8d3-373c01768e73" alt="" width="457"><figcaption><p>Balance sheet (bal) fs bar menu</p></figcaption></figure></div>

The function is automatically completed for you, for example \[bal(Balance Sheet Detail, Trade and Other Receivables, closing)].

<figure><img src="https://3180484653-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKhoFIsurMPEjkuBz9YkN%2Fuploads%2FHq1MFt12JPx8vzHmFykA%2Fimage.png?alt=media&amp;token=57039a82-e3d9-4085-a640-27d09e9b2506" alt=""><figcaption></figcaption></figure>

### Average balance <a href="#functionsforprofitandlosscalculations-averagebalance" id="functionsforprofitandlosscalculations-averagebalance"></a>

The **average** parameter calculates an average of the Balance Sheet account group based on the start date (opening balance) and end date (closing balance) of the period in the Profit and Loss statement. For example, if Current Assets are included in a Profit and Loss statement for the period January to June, the \[bal] function will average the Current Asset values as at the end of December (opening balance) and as at the end of June (closing balance).

Select **bal** as outlined above, expand the account group, then select **average**.

<figure><img src="https://3180484653-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKhoFIsurMPEjkuBz9YkN%2Fuploads%2FUPWknd39htHRMjgVK11m%2Fimage.png?alt=media&amp;token=c1361e21-f564-4b82-9f2f-b38cbc752038" alt=""><figcaption></figcaption></figure>

### Closing balance <a href="#functionsforprofitandlosscalculations-closingbalance" id="functionsforprofitandlosscalculations-closingbalance"></a>

The **closing** parameter inserts the final position of the Balance Sheet account group based on the start and end dates of the period in the Profit and Loss statement. For example, if Current Assets are included in a Profit and Loss statement for the period January to June, the \[bal] function will average the Current Asset values as at the end of December and as at the end of June. This calculation takes into account any material movements in Balance Sheet groups during that period.

Select **bal** as outlined above, expand the account group, then select **closing**.

<figure><img src="https://3180484653-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKhoFIsurMPEjkuBz9YkN%2Fuploads%2Fibb1FNlJPTfpBf1fusGf%2Fimage.png?alt=media&amp;token=3c015fbc-99c7-488e-a3af-ce7057b86ee8" alt=""><figcaption></figcaption></figure>

### Balance Sheet account movement <a href="#functionsforprofitandlosscalculations-balancesheetaccountmovement" id="functionsforprofitandlosscalculations-balancesheetaccountmovement"></a>

The **Movement** parameter displays the difference between the Balance Sheet group value at the start of the period and the value at the end of the period. For example, if January 2023 = 50 and March 2023 = 150, the movement is 100.

Select **bal** as outlined above, expand the account group, then select **movement**.

<figure><img src="https://3180484653-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKhoFIsurMPEjkuBz9YkN%2Fuploads%2FRdYNRbThQLXP1LBXn2HC%2Fimage.png?alt=media&amp;token=3bb47830-6711-4e53-9356-b5ad899f493b" alt=""><figcaption></figcaption></figure>

## \[DaysInPeriod] <a href="#functionsforprofitandlosscalculations-daysinperiod" id="functionsforprofitandlosscalculations-daysinperiod"></a>

The \[DaysInPeriod] function inserts the number of days in the period associated with the financial statement, allowing you to calculate the revenue per day, profit per day, and so on. You can multiply the days by 365 to produce an annualized result.

Click **fx** in the formula bar, then select **Days In Period** from the list. There are no further options to select, the function is inserted directly.

<div align="left"><figure><img src="https://3180484653-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKhoFIsurMPEjkuBz9YkN%2Fuploads%2FK6iprUCAHVT2mX8GMG45%2Fimage.png?alt=media&amp;token=19df9d4e-5f93-4dc9-b4b3-0e8648af9ed5" alt="" width="480"><figcaption></figcaption></figure></div>

The function is automatically completed for you and you can proceed to use it alongside other functions, for example:

<figure><img src="https://3180484653-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKhoFIsurMPEjkuBz9YkN%2Fuploads%2F1YlG4w7gfH86r0iOIRgx%2Fimage.png?alt=media&amp;token=f153a852-f075-4080-854b-ded90c0aa8f8" alt=""><figcaption></figcaption></figure>

## \[stat] <a href="#functionsforprofitandlosscalculations-stat" id="functionsforprofitandlosscalculations-stat"></a>

The Statistics \[stat] function inserts the sum of a measure from a statistical stream, allowing you to calculate revenue or operating profit per customer, or other business insights by combining statistical (non-financial) streams with financial information.

This function is only applicable if your organization has statistical streams added to a database. Your administrator can add non-financial streams to your financial database using Designer.

Click **fx** in the formula bar, then select **Statistics (stat)**. Expand the stream (for example, **Statistics**) to see its measures, then select the one you want (for example, **Headcount**).

<div align="left"><figure><img src="https://3180484653-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKhoFIsurMPEjkuBz9YkN%2Fuploads%2FqmFjxsZSpUJN9Tc4vyqs%2Fimage.png?alt=media&amp;token=69387c68-72b0-47be-8499-05ebc4c65b7c" alt="" width="470"><figcaption></figcaption></figure></div>

The function is automatically completed for you. It includes the stream followed by the measure, for example \`stat(Statistics, Headcount)\`:

<figure><img src="https://3180484653-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKhoFIsurMPEjkuBz9YkN%2Fuploads%2FPkb5lpcljhb50dDQ2EJc%2Fimage.png?alt=media&amp;token=7af7fcd3-82b6-4011-9ec6-cb00dcb30383" alt=""><figcaption></figcaption></figure>

## \[avg] <a href="#functionsforprofitandlosscalculations-avg" id="functionsforprofitandlosscalculations-avg"></a>

The Average \[avg] function inserts the average of the values in a measure from a non-financial stream, for a specific period. For example, if you want to know the average number of units sold during the year (monthly basis), the \[avg] function will calculate the average of the monthly balances.

This function is only applicable if your organization has non-financial streams added to a database. Your administrator can add such streams to your financial database using [Designer](/administration/designer.md).

Click **fx** in the formula bar, then select **Statistical average (avg)**. Expand the stream (for example, **Statistics**) to see its measures, then select the one you want (for example, **Headcount**). The function is automatically completed for you. It includes the stream followed by the measure, for example \`avg(Statistics, Headcount)\`:

<figure><img src="https://3180484653-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FKhoFIsurMPEjkuBz9YkN%2Fuploads%2FwYUBYaVmJolaypdz5XwM%2Fimage.png?alt=media&amp;token=54b54d5b-5d9a-470b-8f43-39c9e809615d" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.phocassoftware.com/financial-statements/managing-statements/customize-a-financial-statement/customize-calculations/functions-for-profit-and-loss-calculations.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
