# Insert calculated columns

With Inforiver, you can insert a new calculated row, column, or measure at the visual level in your Power BI table or matrix-style reports without writing DAX. The rows, measures, and columns so created can also be formatted, rearranged, and utilized for downstream calculations.

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.

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

### 1. Visual measure

Let us take this example, where we have sales data for two years, 2024 and 2023, by quarter. We will now try to insert a measure that calculates the percentage variance using the formula (2024 Actuals - 2023 Actuals) / 2023 Actuals.

<figure><img src="/files/t508L3dTRgTqegBDxRqK" alt=""><figcaption><p>Sales actuals by quarter</p></figcaption></figure>

**STEP 1:** To insert a measure, select **Insert Formula** from the **Insert** ribbon. A side panel opens on the right.

<figure><img src="/files/Ff9GS7T2QqnK5cxF9Zh6" alt=""><figcaption><p>Insert formula option in the toolbar</p></figcaption></figure>

**STEP 2:** You will see two options in the **Insert as** field: **Visual Measure** (the default) and **Visual Column**. Let us go ahead with the default option - **Visual Measure.**

The visual measure behaves like a measure, except that it is inserted directly in your visual (bypassing the data model). In the image below, note that this new measure is inserted under each quarter.

<figure><img src="/files/QOUNZv419FO1gw4ZSDrd" alt=""><figcaption><p>Inserting a visual measure</p></figcaption></figure>

**STEP 3:** Once you place the cursor inside the formula editor, you will see a context assistant pop-up. You can access dimension/measure references or functions through this context assistant.

<div><figure><img src="/files/g383tLEQj8gkPrDyJvKt" alt=""><figcaption><p>List of references</p></figcaption></figure> <figure><img src="/files/B34QlhqhDz60vPFXGP0L" alt=""><figcaption><p>List of functions</p></figcaption></figure></div>

**STEP 4:** Let us go ahead and start typing in values. As you key in a formula, the **References** list automatically refreshes to show a narrower set of options.&#x20;

{% hint style="info" %}
You can directly select a column from the table to insert in the formula editor. Note that measures can not be referred to this way. To insert a visual measure or a visual column in your formula, you need to use the **References** tab in the context assistant.
{% endhint %}

<figure><img src="/files/EW6kOA0sw5FYQvKHEiFE" alt=""><figcaption><p>Using intellisense to narrow down the reference list</p></figcaption></figure>

**STEP 5:** We will go ahead and complete the formula as shown below. The rectangular parentheses in the formula indicate that these are not normal text but references to other measures.

<figure><img src="/files/MTbZ2eD9MlAbWcolJP6Q" alt=""><figcaption><p>Enter the formulaa</p></figcaption></figure>

**STEP 6:** Give the calculated measure a relevant name, say 'Variance %', and click **Create**.

<figure><img src="/files/Geul53re0dQvuaciDDSQ" alt=""><figcaption><p>Naming a calculated column</p></figcaption></figure>

**STEP 7:** You would have now inserted a calculated measure in your report. However, you will notice that the values are in absolute numbers and not in percentage terms.

<figure><img src="/files/FGNle4fqd8wtTTn7bVgn" alt=""><figcaption><p>Formula measure created</p></figcaption></figure>

**STEP 8:** To convert the values to a percentage format, click on the **%** icon from the **Home** tab. As you do this, you will also notice that the formula bar at the top of the matrix shows how the measure is calculated.

<figure><img src="/files/GwGtQ6gZrabcY4CTPH1f" alt=""><figcaption><p>Formula measure converted to percentage</p></figcaption></figure>

We have successfully inserted a calculated measure at the visual level in our Power BI matrix report.

### 2. Visual column

A calculated column works differently from a calculated measure. Let's consider two examples.

#### Example 1:

**STEP 1:** Let us calculate the quarter-on-quarter change from Q3 to Q4. Select the **Visual Column** option. Note that a visual column always appears at the end, outside any category or category hierarchies seen in columns.

<figure><img src="/files/GMZrnY7SGD96Mtkx8gL5" alt=""><figcaption><p>Inserting a visual column</p></figcaption></figure>

**STEP 2:** You will also notice that the **References** section is a bit different. While creating a [new measure](#1.-visual-measure), the **References** section only listed the available measures (2024 Actuals and 2023 Actuals). This time, it displays every instance of the individual measures (e.g., Q2 - 2024 Actuals, Q3 - 2023 Actuals, etc.). Using this, you can traverse right up to the leaf node of any column hierarchy.

<figure><img src="/files/rlJJDCuqEyJImiqIaB70" alt=""><figcaption><p>References when creating a visual column</p></figcaption></figure>

**STEP 3:** Enter a title and the formula and click **Create**.

<figure><img src="/files/PNAFW3NDqufjNaLzKPVS" alt=""><figcaption><p>Configuring a calculated column</p></figcaption></figure>

**STEP 4:** You will see the values updated in the report.

<figure><img src="/files/Iou286qF2dGdJ3UpaaKr" alt=""><figcaption><p>Visual column created</p></figcaption></figure>

#### Example 2:

Let's consider an example where we use built-in functions. In the example below, we want to insert a column that displays the multiplier - 2022 Actuals/2022 Plan.&#x20;

**STEP 1:** Click **Insert Formula**. Notice that there is no option to insert as a visual measure or column. This is because the report doesn't have a column hierarchy.

<figure><img src="/files/QVJTBjwnPrUB0lIz3DaH" alt=""><figcaption><p>Visual columns are automatically created when the report doesn't have a column hierarchy</p></figcaption></figure>

**STEP 2:** Enter the title and the formula. Click **Create**.&#x20;

<figure><img src="/files/Iam18ti97otBUT3SRHXb" alt=""><figcaption></figcaption></figure>

**STEP 3:** Notice that there are Div/0! errors for two of the rows. There are two ways to deal with calculation errors.&#x20;

<figure><img src="/files/3LZwtVA7afegElbwmcKR" alt=""><figcaption><p>Calculation errors in the visual column</p></figcaption></figure>

**i) Display settings -> Suppress calculation errors**

In the **Home** tab, click on **Display** settings. In the side panel, go to the **Numbers** tab. Turn on the **Suppress Calculation Errors** toggle. A new field called **Custom Error Text** is enabled.

<figure><img src="/files/gEstHq6gHIhYrdptDEz9" alt=""><figcaption><p>Suppress calculation errors</p></figcaption></figure>

You can define a custom text, such as 'N/A', 'ERROR', or leave it blank. In the image below, we have entered 0. You can see the changes in the rows.&#x20;

<figure><img src="/files/UyRTEroA4li5p0BOPf0C" alt=""><figcaption><p>Replacing error messages with custom text</p></figcaption></figure>

**ii) Using IFNA function**

Another way to handle calculation errors is by using the IFNA function. When an expression results in an error, you can replace it with a value as shown below.&#x20;

<figure><img src="/files/K4rGDSB5tOQ1sBmBu4KV" alt=""><figcaption><p>Handling errors with the IFNA function</p></figcaption></figure>

**iii) Using the IF function**

Another indirect approach would be to use IF/nested IF statements to define the value when the expression results in an error.&#x20;

<figure><img src="/files/K7lAwdtfeKDeEbQuEBUi" alt=""><figcaption><p>IF function to handle errors</p></figcaption></figure>

### **3. Row and column aggregation for formula measures** &#x20;

Inforiver automatically sets the row aggregation to formula and the column aggregation to sum for formula measures. You can override the default aggregation a required.&#x20;

Note: When you select weighted average as the row aggregation type, the column aggregation will be set to weighted average and cannot be overridden.&#x20;

You can view and edit the aggregation for formula measures from the Manage aggregation interface. [Learn more about aggregation features in Inforiver.](/working-with-inforiver/manage-aggregations.md)

<figure><img src="/files/B3eNMMovgTSQyQO0ZDTJ" alt=""><figcaption><p>Row and column aggregation for formula fields</p></figcaption></figure>

#### Resources

[Insert Formulas, Columns and Aggregation](https://www.youtube.com/watch?v=hjPAbuYJUSc)

[Visual calculations using Inforiver](https://inforiver.com/webinars/visual-level-formula-calculations-powerbi/)

[Calculate remaining budget in Power BI (without using DAX)](https://inforiver.com/blog/general/calculating-remaining-budget-powerbi/)

[Insert calculated measure or column in Power BI](https://inforiver.com/blog/feature-highlights/insert-visual-measure-column-calculations-in-microsoft-power-bi/)


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.inforiver.com/working-with-inforiver/4.-adding-business-logic-and-formulae/insert-calculated-columns.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
