# Add Formulas

Formulas, as the name indicates are calculations that you could define in ManageEngine Analytics Plus to help you create the required reports. ManageEngine Analytics Plus provides a powerful formula engine to create any type of calculations required, to enable creating the required reports. ** Formulas ** are mathematical expressions that you create, which contains any combination of numbers, references of table columns, operators and functions etc. ** Functions ** are predefined mathematical formulas which are designed to perform specific well-known calculations.

ManageEngine Analytics Plus supports different flavors of formulas. The following is a summary of the various types of formulas that are supported in ManageEngine Analytics Plus:

**Custom Formula Columns:**These are formula types where you could add a*new column*to your data table, whose values are derived based on the calculation/formula defined. You can define any powerful mathematical formula which uses the table columns in combination with operators and in-built functions. As the output of the formula adds a new column in the table is called a*Formula Column.***In-built Formulas:**ManageEngine Analytics Plus provides a useful set of in-built custom formulas, available by default, to perform common calculations easily. These formulas can be applied only to single column. The result of a calculation (formula) will be added as another column to the base table.

**Aggregate Formulas:**Aggregate Formulas are formulas where you should use aggregate functions (SUM, AVG..) in the calculation. The result of Aggregate Formulas**will not be added**as another column in the base table. They will just be associated to the table on which it has been created and can be used in creating reports (Charts, Pivot Tables and Summary Views) like any other table columns.

## Custom Formula

ManageEngine Analytics Plus allows you to define your own powerful formulas to meet your specific reporting requirements. This enables you to easily perform from simple calculations such as addition and subtraction to a complex combination of in-built functions. As the output of the formula adds a new column in the table is called a* Formula Column*. You can use these formula columns in creating reports in the same way you use other columns in a table.

ManageEngine Analytics Plus provides you with a variety of in-built functions which are predefined mathematical formulas which are designed to perform specific well-known calculations easily. These in-built functions can be used in combination with the table columns and basic arithmetic operators like +, -, / and * to create your formula column.

To create and use custom formula columns:

- From the
**Explorer**tab of the workspace, select the table to which you want to add the formula column. - Select
**Add > Formula Column**option from the toolbar or select a column in the table and choose**Formula Column**from the right click pop-up menu. - The
**Formula Column**dialog box will open as shown below. This dialog box provides easy access to the names of the columns in your table, as well as to many of the in-built functions that are available to create formulas. A brief description of the function with syntax and an example will be displayed at the bottom of the dialog box when you hover your mouse over a function. - In the
**Formula Column**dialog box, select the columns and functions that you want to insert from the list under the**Columns**and the**Function**boxes.

For example, to build a custom formula that adds particular number of days to a given date:

- Select the
**Add Date**function under the**Functions**box. You will notice that**adddate()**syntax appears in the**Formula**text box. - In the
**Formula**text box, position the cursor in between the parenthesis, select the date column to which you wanted to add date using the**Columns**option. - Enter the number of days (say 10) that you want to add separated by a comma.

To create a formula column with this expression, type column name in the** Formula Column Name** text box and then click ** OK**. A new formula column will be created in your table as shown below.

You can edit the formula column any time by right clicking on the formula column listed in the table and clicking **Edit Custom Formula** in the popup menu. Also refer to View/Edit Formulas to know how you could view all the formulas defined on a table and handle edition or deletion of the same.

## Quick Add option for Formula Columns

ManageEngine Analytics Plus provides an easy and convenient way to add formula columns which are based on a limited set of widely used functions. You can find this quick add option as follow.

- Select a column based on which you want to add the formula column.
- Click
**Add > Add Formula**option on the toolbar.

- ManageEngine Analytics Plus automatically identifies the data type of the column selected and displays a list of widely used pre-defined formulas which are applicable to that as shown in the screenshot below.
- On selecting the required formula from the list, ManageEngine Analytics Plus applies the formula on the corresponding column and adds a new formula column, at the right end of the table.

## In-built formula column functions

Analytics Plus offers a variety of in-built functions which are predefined mathematical formulas designed to perform specific well-known calculations easily. Click here to know about the list of inbuilt formula column functions supported by Analytics Plus.

## Creating Formulas Over Formula Column

Formula columns are similar to other columns of the table. You can make use of existing formula columns while creating a new formula column, as you do with other columns of the table. Reusing existing formulas column to create new formula columns helps you create powerful formula combination, as well as eases in maintenance of these formula structure in your workspace. Refer to the above section to know how to create formula column.

## Creating Reports Using Custom Formula Column

Custom Formula columns can be used while creating reports as you would use a column in a table. When you create a new report over the table, in which you have added the custom formula column, all these formula columns will be listed in the Columns list pane on the left, which can be drag and drop to create the report.

You can apply functions on the formula column, as you do for other columns, using the combo box that is displayed over the column when dropped in the design area of the report.

## Sharing Custom Formulas

Once a Custom Formula column is created, it behaves like any other column in a table. When you share a table, all the existing custom formula columns will also be shared to the user.

Note:

- The shared user will not be able to edit, delete or format the shared formulas. Also the shared user will not be able to add his own formula column over the shared table, unless the shared user is a Workspace Owner.

## Aggregate Formulas

In reporting the most common data analysis that we do is to apply aggregate functions over the data (like SUM, AVG, COUNT etc.,) and analyze the same. The important aspect to be taken care in such calculations is to compute the aggregation in the context in which the function is applied to provide accurate results. Aggregate Formulas in ManageEngine Analytics Plus is meant to address this need.

Aggregate Formulas are formulas that you define in ManageEngine Analytics Plus which uses at least one aggregate function (SUM, AVG..) in the calculation. The output of such calculations is always a numeric value (metric). Aggregate formulas are mainly used in creating powerful reports. These formulas can be used in Charts, Pivot Tables and Summary View report types in ManageEngine Analytics Plus .

- The result of an Aggregate Formula is always a numeric value.
- Aggregate Formulas
**will not be added**as another column in the base, it is associated with, like Custom Formulas. But it will be available for report creation when you create a report over the table (listed as part of the columns list). - The value of an aggregate formula will be computed for each data point that is displayed in the report in which it is used (i.e., the result is not just a single value). This makes it very powerful.
- Aggregate formula can be constructed in a similar way as that of a Custom Formula.

ManageEngine Analytics Plus offers a range of in-built aggregate functions which can be used as part of the Aggregate Formulas. You can construct the formulas using these in-built aggregate functions combining it with the basic arithmetic operators like +, -, / and *.

## Creating Aggregate Formulas

To create an aggregate formula:

- Select
**Add > Aggregate Formula**option from the toolbar as shown below. - The
**Add Aggregate Formula**dialog box will open as shown below. This dialog box provides easy access to the names of the columns in your table, as well as to all the in-built functions that are available for you to create the formula. A brief description of the function with syntax and an example will be displayed at the bottom of the dialog box when you hover your mouse over a function. - In the
**Formula Column Name**text box, type the name that you want to give to the formula. - Select the data type of the aggregate result of the formula, using the
**DataType**drop down menu. The data type should only be a Numeric value, hence the possible types are Number, Positive Number, Decimal Number, Currency and Percent. - In the
**Formula**text area provide the actual formula. You can select the columns and functions that you want to insert into the formula from the list from the**Columns**and the**Function**boxes.Note: You can also insert columns from related tables joined through Lookup Column. The drop-down lists all the parent table associated with the base table. Select the required table, the columns in this table will be listed below. You can insert this in the formula by clicking.

- For example, to apply an aggregate formula to calculate
*% Profit*the formula could be something like**(SUM("SALE")- SUM("COST"))/SUM("COST")*100**as shown in the screenshot below. - Click
**OK**.

The result of Aggregate Formulas ** will not be added as a column ** in the base table. It will be listed in the column panel while creating reports. You can access (view) or edit it by clicking** Add > Edit Formulas** in the toolbar. Viewing & Editing Formulas is discussed in the next section.

## In-built Aggregate Functions

While you create an aggregate formula you can use a wide range of powerful in-built functions that are supported by ManageEngine Analytics Plus. You can use the in-built functions, that are applicable while creating custom formulas, even when you create an Aggregate formula, provided it meets the required conditions for an Aggregate formula. There are also specific functions which are more relevant & applicable for creating Aggregate formulas. Click here to know about the built-in aggregate functions.

## Creating Aggregate Formula over existing Aggregate Formulas

ManageEngine Analytics Plus enables you to build aggregate formulas using existing aggregate formulas. Reusing existing formulas to create new aggregate formula helps you create powerful formula combination, as well as eases maintenance of these formula structure in your workspace.

When you create a new aggregate formula, existing formulas will be listed in the ** Click to Insert Columns** box along with other columns. All the aggregate formulas will be indicated in brown with the **∑** symbol. You can insert these formulas into your new formula definition by clicking them, as you do for the other columns in the table.

*For example, Let's assume that you have already calculated profit percentage and total cost and you want to calculate total profit gained. Then you can use the existing aggregate formulas to calculate total profit gained. The formula could be something like ("Total Cost" * "Profit") / 100.*

## Creating Reports using Aggregate Formulas

Aggregate formulas can be used while creating all reports (charts, pivot tables and summary views) as you would use a column in a table. When you create a new report over the table, in which you have added the aggregate formula, all the formulas will be listed in the Columns list pane on the left, which can be drag & dropped to create the report.

The following screenshot shows the % Profit aggregate formula, that we added, listed in the columns list page. All the aggregate formulas will be indicated with an icon which contains the symbol.

From the ** Explorer** tab of the workspace, select the table to which you want to add the aggregate formula.

Aggregate formulas can be used in the report as you use any other data columns in the table. The value of the aggregate formula will be computed for each data point that is displayed in the report in which it is used (i.e., the result is not just a single value). In the chart shown in the screenshot below, the percentage of profit (%Profit) is plotted against the Year. As you see, the value of the Profit percentage is calculated for each year and plotted in the graph.

When you use an Aggregate formula in a report, you will not be able to apply other functions on the formula (as you do for other columns). The function will always be selected as 'Actual' and cannot be modified.

## Sharing Aggregate Formulas

With respect to sharing and collaboration, Aggregate Formulas behave similar to how a column in a table behaves. When you share a table, all the aggregate formulas that are created over the table will be also shared to the user to whom you are sharing the table. Hence the shared user will be able to use these formulas while creating any report over the data table.

Note:

- The shared user will not be able to edit, delete or format the shared aggregate formula, but can just use it in report creation. Also the shared user will not be able to add his own Aggregate formulas over the shared table, unless the user is a Workspace Owner.

## View/Edit Formulas

ManageEngine Analytics Plus allows you to view, edit, format and delete all the formulas defined for a table through the ** Edit Formula ** option. You can view & edit both Custom Formulas and Aggregate Formulas using this option. To view/edit existing custom or aggregate formulas:

- Select the required table.
- Select
**Add > Edit Formulas**option from the toolbar. - The
**Edit Formula**dialog box with a list of all the formulas associated to the table will open as shown below:On hovering over a specific formula, the

**Edit**,**Remove**and&**Format**options are available. **Edit Formula:**You can edit the constructed formula using the**Edit**link provided next to the corresponding formula. The**Edit Formula/ Aggregate Formula**(depending on the type of formula) dialog box will open, and you can modify the existing formula the same way you would when creating a new formula.**Delete Formula:**You can delete an existing Formula any time from the table using the**Remove**link provided next to the corresponding formula.**Format Formula:**You can change the format of the Formula result, like alignment, decimal places, date format, currency symbols etc., depending on its data type of the formula using the**Format**link provided. It's similar to how you format a data column. Refer here to know how to format a column.