# Insert calculated rows

The Inforiver Premium Table provides an option to insert calculated rows using an intuitive formula editor. The Excel-like formula engine supports 50+ functions (logical, boolean, math functions, and more). The formula editor provides syntax, examples, and features such as autocomplete, multi-line support, and more to help users create and troubleshoot formulas.

<figure><img src="https://2428652681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsB9HAei8v4FfKkH9M4gw%2Fuploads%2FdyBRA1oDeSNJyVmZMejk%2FInsert_rows_gif.gif?alt=media&#x26;token=a6c92cdc-11e7-48a1-be6d-91c0afce1339" alt=""><figcaption><p>Insert Rows in Table</p></figcaption></figure>

{% hint style="info" %}
Refer to [formula syntax](https://docs.inforiver.com/premium-table/formula-syntax) for a detailed list of functions, operators, and identifiers that can be used for calculations.
{% endhint %}

Let us take this example, where we have sales data by category and subcategory. Let us add a new row above the 'Computer' category, which is calculated as the minimum of all of its subcategories.

Select the row above which we need to insert the new row. In the Insert tab, click on the **Insert Row** dropdown. Select the **Calculated Row** option.

<figure><img src="https://2428652681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsB9HAei8v4FfKkH9M4gw%2Fuploads%2Fe7bSD9dIVeqpTssnG0d7%2Fimage.png?alt=media&#x26;token=5b4e3f15-00dc-40b8-b1a0-b4484cc82341" alt=""><figcaption><p>Inserting a calculated row</p></figcaption></figure>

A blank row gets inserted, and a side panel opens up as shown.

<figure><img src="https://2428652681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsB9HAei8v4FfKkH9M4gw%2Fuploads%2FfCvwgC1LSlupFs1G4CzS%2Fimage.png?alt=media&#x26;token=953f9fb9-e06c-4ca6-b0e1-5d4f0f2b182e" alt=""><figcaption><p>Create calculated row</p></figcaption></figure>

### 1. Formula editor

1. Rename the title and click on the formula editor. You can see a list of available functions in the Functions tab.

<figure><img src="https://2428652681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsB9HAei8v4FfKkH9M4gw%2Fuploads%2Fq4cDBGdXqrevWNKWtzwU%2Fimage.png?alt=media&#x26;token=85f66c5c-1126-4e5d-8766-84683b4a729e" alt=""><figcaption><p>Enter the title</p></figcaption></figure>

2. As you start typing, Inforiver's IntelliSense narrows down the list of functions to match the entered text. Click on MIN.

<figure><img src="https://2428652681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsB9HAei8v4FfKkH9M4gw%2Fuploads%2FvPqeACBPLJej8GkCAWaa%2Fimage.png?alt=media&#x26;token=b041b7c3-b862-4fee-9b45-cf514b6d69e8" alt=""><figcaption><p>Select function</p></figcaption></figure>

3. The formula editor displays the syntax for the function. Click on the arrow highlighted.

<figure><img src="https://2428652681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsB9HAei8v4FfKkH9M4gw%2Fuploads%2FyTZnXk09JPHVa4Tdc5HL%2Fimage.png?alt=media&#x26;token=c2deb5fd-0bc4-4eff-80ba-89f35895d52f" alt=""><figcaption><p>Formula syntax</p></figcaption></figure>

4. The Premium Table also displays a description of the function and a detailed explanation of the arguments with examples.

<figure><img src="https://2428652681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsB9HAei8v4FfKkH9M4gw%2Fuploads%2FVsxiWe7p0Xc8t8TfL6Bb%2Fimage.png?alt=media&#x26;token=a342c6ba-0a91-4037-abd0-6ab48f8065c0" alt=""><figcaption><p>Function description and examples</p></figcaption></figure>

5. To insert a reference to a particular row, click on the required cell references when the cursor is placed in the formula editor.&#x20;

<figure><img src="https://2428652681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsB9HAei8v4FfKkH9M4gw%2Fuploads%2FvjTTKC0DmjONdKkVm9rl%2Fcalcrow1.gif?alt=media&#x26;token=0790f409-762a-4392-bc56-56f0850dc173" alt=""><figcaption><p>Referencing rows by selectingt them</p></figcaption></figure>

6. The other way is to use the References tab. To access *Desktops*, you need to type *Computers\_Desktops*. As you start typing '*Com..'*, the references get narrowed down. Select the required rows from the pop-up.

<figure><img src="https://2428652681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsB9HAei8v4FfKkH9M4gw%2Fuploads%2F3Ex50IYWWUStUNzBtEh9%2Fimage.png?alt=media&#x26;token=7c76ad38-68c6-4ce5-b087-5d0e8537cdf5" alt=""><figcaption><p>Inserting a reference from the dropdown</p></figcaption></figure>

7. If no further changes are required, click on **Create** after entering your formula. The calculated row gets created as shown.

<figure><img src="https://2428652681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsB9HAei8v4FfKkH9M4gw%2Fuploads%2FaFHDO5sgCS3z6abNGTBA%2Fimage.png?alt=media&#x26;token=93e43b65-27a0-4d38-be1b-05481b9326b5" alt=""><figcaption><p>Calculated row is inserted</p></figcaption></figure>

{% hint style="info" %}
To view the underlying logic for calculated data, click on the result cell to preview the formula used, in the formula bar.
{% endhint %}

**Note:**

Any errors in the formula can be easily located with clear and concise error messages. In the maximized formula editor view, you will also notice line numbers, allowing you to quickly locate and fix errors.

<figure><img src="https://2428652681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsB9HAei8v4FfKkH9M4gw%2Fuploads%2F1wm3ZCvhhRP8IQQAA95e%2Fimage.png?alt=media&#x26;token=c78a3d44-f044-4db7-8288-3bb7d9acb1d4" alt=""><figcaption><p>Maximized formula editor</p></figcaption></figure>

### 2. Manage Inserted Rows

The inserted row can be customized using a few options based on our needs. To access these options, go to **Insert > Manage Rows** and select the required row.&#x20;

<figure><img src="https://2428652681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsB9HAei8v4FfKkH9M4gw%2Fuploads%2Fgavr7yzknWILMX4oDY5M%2Fimage.png?alt=media&#x26;token=9dc3b6f9-e4e4-4d42-ad4a-2f427a8fe6bf" alt=""><figcaption><p>Manage Rows</p></figcaption></figure>

Let's take a look at all of the options below:

### 3. Include in total

Select the **Include in total** checkbox to include the calculated row in the grand total. Click **Update**. The grand total is updated.

<figure><img src="https://2428652681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsB9HAei8v4FfKkH9M4gw%2Fuploads%2F9hS473vItLMpbNYtaVIZ%2Fcalcrow2.gif?alt=media&#x26;token=27198edb-62f6-4b36-8a28-5ae3c5e59ab8" alt=""><figcaption><p>Including calculated row in total</p></figcaption></figure>

### 4. Include in Charts

1. To include the calculated row when using row-level charts, check the **Include in Charts** checkbox. Click **Update.**

{% hint style="info" %}
The 'Include in Charts' checkbox is enabled only when the 'Include in total' option is unchecked.
{% endhint %}

<figure><img src="https://2428652681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsB9HAei8v4FfKkH9M4gw%2Fuploads%2FuUT1rQrCX7cdHalVfCfv%2Fimage.png?alt=media&#x26;token=e21a776f-ee21-42e7-a302-e68d65dec3d5" alt=""><figcaption><p>Include the row in charts</p></figcaption></figure>

2. Now, let's add a bar chart to Actual Sales. Click on the column and then select the highlighted bar chart from the 'Home' tab.

<figure><img src="https://2428652681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsB9HAei8v4FfKkH9M4gw%2Fuploads%2FVRqvxTFL6puvNbShub7B%2Fimage.png?alt=media&#x26;token=3caaa939-3588-436e-829d-be46ddf710dc" alt=""><figcaption><p>Adding a chart</p></figcaption></figure>

3. Note that the calculated row, 'Other Accessories,' is also visualized using a bar chart.

<figure><img src="https://2428652681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsB9HAei8v4FfKkH9M4gw%2Fuploads%2Fst5tCQ59CEulxY29eF3C%2Fimage.png?alt=media&#x26;token=91f1a701-2437-41c8-84cf-456c0b296e30" alt=""><figcaption><p>Bar chart shown for calculated row</p></figcaption></figure>

4. When you uncheck the 'Include in Charts' checkbox and click on 'Update', you will see that the calculated row is no longer displayed with the chart.

<figure><img src="https://2428652681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsB9HAei8v4FfKkH9M4gw%2Fuploads%2FzkSwUYBVsxzniQiMhjEu%2Fimage.png?alt=media&#x26;token=f41cc5fb-b50e-44cc-a176-2bacec3f3a47" alt=""><figcaption><p>Calculated row shown as number without chart</p></figcaption></figure>

### 5. Evaluate column before rows

When inserting calculated rows, you may want the results of the calculated columns to take precedence over the calculated row results or vice versa. This behavior can be configured using the 'Evaluate column before rows' option.&#x20;

Let's consider an example where we are [inserting a calculated column](https://docs.inforiver.com/premium-table/working-with-premium-table/4.-adding-business-logic-and-formulae/insert-calculated-columns) for calculating the variance between the 'Actual Sales' and 'Forecast'.&#x20;

<figure><img src="https://2428652681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsB9HAei8v4FfKkH9M4gw%2Fuploads%2FWP8vIjQfLLSCmwgoHaVo%2Fimage.png?alt=media&#x26;token=1b16e305-f655-46f2-960c-5b453eeed75d" alt=""><figcaption><p>Calculated Column</p></figcaption></figure>

Let's insert a calculated row using the steps [mentioned above](#id-1.-formula-editor):

<figure><img src="https://2428652681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsB9HAei8v4FfKkH9M4gw%2Fuploads%2FqBbWu7VQh4AcgbwbUVkH%2Fimage.png?alt=media&#x26;token=51f0cfaf-7094-4360-87b2-3b0a4d1f3d1b" alt=""><figcaption><p>Calculated Row</p></figcaption></figure>

You can see that the calculated column value is empty for the calculated row.

When 'Evaluate columns before rows' is enabled, the variance between the configured columns is calculated, overriding the calculated row's result.

<figure><img src="https://2428652681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsB9HAei8v4FfKkH9M4gw%2Fuploads%2FlRD41Jyg4h0Ph9D0mAjY%2Fimage.png?alt=media&#x26;token=330a5ac3-25f4-46fe-8bd3-67888cc2a358" alt=""><figcaption><p>Evaluating columns before rows</p></figcaption></figure>

### 6. Scaling factor

In some cases, the values in calculated rows may not match the number scaling specified at the report level. You can use a custom scaling factor depending on the nature of the calculation.

<figure><img src="https://2428652681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsB9HAei8v4FfKkH9M4gw%2Fuploads%2FdaBT7GVKKzZzoMGJNpw3%2Fimage.png?alt=media&#x26;token=79f97226-0588-4921-815b-c0e984b9d485" alt=""><figcaption><p>Scaling Factor</p></figcaption></figure>

### 7. Bind for Cross filter/RLS

You can enable the Bind for Cross filter/RLS option – this ensures that cross-filter selections and RLS settings apply to calculated/manual input rows that reference other rows.&#x20;

For example, if this option is not enabled, a manager in charge of a specific product (say, cell phones) will see all manually inserted rows referencing data from other products (such as audio, cameras, and so on) that were visually created.&#x20;

<figure><img src="https://2428652681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsB9HAei8v4FfKkH9M4gw%2Fuploads%2F4V1z6Ofn1X12O4MQWs7n%2Fimage.png?alt=media&#x26;token=868f9256-fce2-4320-977d-45ca29b7c0fa" alt=""><figcaption><p>Calculated row in Audio visible to other category person</p></figcaption></figure>

To avoid this, you can bind inserted rows to a **reference row** or a **dimension category** by selecting the appropriate one.

* **Binding to a reference row**

To select a particular reference row, choose *Row* from the **SelectionType** dropdown and choose the required row. Click on **Update**.

<figure><img src="https://2428652681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsB9HAei8v4FfKkH9M4gw%2Fuploads%2F0sfvv1XmkL9fTMFtbTpa%2Fimage.png?alt=media&#x26;token=ccb635fc-1298-4748-b7e8-3f001e0c9c43" alt=""><figcaption><p>Binding to a reference row</p></figcaption></figure>

* **Binding to a Dimension category**&#x20;

To bind the inserted row to a particular dimension category, choose *Dimension member* from the **SelectionType** dropdown and select the dimension. Click on **Update**.

<figure><img src="https://2428652681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsB9HAei8v4FfKkH9M4gw%2Fuploads%2FjCtiBI0oe9hzACBz9Bno%2Fimage.png?alt=media&#x26;token=12cf27e0-ee63-4015-9658-143de2b149b5" alt=""><figcaption><p>Binding to a dimension category</p></figcaption></figure>

Notice how the inserted row is hidden for other users but visible for 'Audio' category users.

<figure><img src="https://2428652681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsB9HAei8v4FfKkH9M4gw%2Fuploads%2FyH2n88Hn8YlVdk8ozLMX%2Fimage.png?alt=media&#x26;token=22426db7-53f7-4503-957e-dd452ae08e88" alt=""><figcaption><p>Inserted row hidden for other roles</p></figcaption></figure>

<figure><img src="https://2428652681-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsB9HAei8v4FfKkH9M4gw%2Fuploads%2F61XTRq6M4F9PEjtIYOCC%2Fimage.png?alt=media&#x26;token=4c66727b-05d0-49a0-9805-c7f8ac1e69b4" alt=""><figcaption><p>Inserted row visible for the relevant role</p></figcaption></figure>
