What are models?

Models are configurable objects that combine data queries with spreadsheet-like templates, enabling you to build advanced reporting and planning models.

Let's look again at our diagram (which we explained in the introduction) :

diagram models

Models are free-format templates which you can build in the same way as you would build an Excel spreadsheet. Models can contain multiple sheets, and each sheet contains a layout, cell values, cell formatting, formulas, and functions.

But unlike Excel spreadsheets, models contain only your logic unencumbered with data: realtime data is pulled into the model during Run model. This ensures that models always work with updated and accurate data, and your logic never gets compromised.

In other words: optimal separation of logic and data, which keeps your reporting and planning processes very robust.

✭ Tip:
  • Although models look like spreadsheets, please do not confuse them. Don't try to replicate complex spreadsheets into a model. Models are powerful templates, and they can achieve the same (and more!) in a much simpler way.

Model types

Models can be defined for 2 different purposes:

  • Reporting - build your own custom reports. You can combine very diverse types of data into one model, apply your own format, add formulas, functions, and calculations, and integrate charts, icons, links, and images in your model.
  • Planning - build interactive planning models. You can pull data into your model, define cell editors, and allow users to enter data into the model in designated cells. You can apply formulas, functions, and calculations, and save the results back into data sets.

Create a model

You can create a model in two ways:

  • Click on Define - New in the sidebar menu.
  • Click on the Actions - Create new button of an existing model. This also enables you to make a copy of an existing model.

Either way, the rest of the process is the same, and you can enter a name for your new model, set user permissions for it, and define its sheets and queries:

screenshot define models

When you create a model, focus on the template, don't enter real data. You can integrate data through queries, which we'll explain below. The above example -with just a few rows- is a fully functional model.

You can use the toolbar to populate and format the cells, create formulas, set named ranges and conditional formatting - all in the same way as in Excel. You can also insert objects, such as cell editors, named ranges, sparklines, images, web links etc. XLReporting supports all common spreadsheet functionality. You can create multiple sheets if needed.

Settings

You can define the settings for the model via these fields:

  • Name - enter a name. This must be unique within all your models.
  • Description - enter an (optional) description. This is helpful to document your various models.
  • Active/locked - activate or lock a model. When locked, the model can not be used.
  • Group - select how this model is to be shown in the menu navigation.
  • User roles - select one or multiple user role(s) to restrict access to this model. If you leave this blank, all users have access.
  • Script - create a script to process query data before it is being inserted into the model. This option is for advanced use, and only visible if your user role has the relevant permissions. Read more about scripts.

Queries

Queries enable you to define how data sets should be integrated into your model. A model can contain multiple queries. During Run model, all its queries are simultaneously executed against the XLReporting database and the resulting realtime data is inserted into the model.

You can define queries by clicking on the Define button:

screenshot define models queries

This opens a dropdown menu with further options:

  • Add a new query - create a new query.
  • Edit this query - edit the definition of the currently selected query.
  • Delete this query - delete the currently selected query.
  • Hide the preview - hide the preview with query results.

When you add a new query, or edit an existing query, the first step is to choose the type of query and determine the name and settings for that query:

screenshot define models queries add

You can choose between 3 types of queries:

  • Report - read data from your data sets, and insert the entire formatted report into a designated cell range in your model.
  • Data - read data from your data sets into memory, and then use cell functions to pull specific data into individual cells in your model.
  • Save - read cell ranges in your model and save the information into your data sets.

If you select Report or Data, you need to select the source data set: this is the primary data set that you want to retrieve information from. All its linked data sets will be automatically included, and you can create a report in exactly the same manner as Define reports, including converting the data, filtering the data, and setting the report options and fields position.

If you select Save, you need to select the target data set: this is the data set into which you want to import the data from your model. You can create the column mapping in the exactly the same manner as Define imports, including mapping the columns, converting the data, filtering the data, and the settings for inserting or replacing data.

In Options when running the model you can select a number of features:

  • Insert data rows - should the data be placed in dynamically inserted rows, or should the data overwrite the existing rows? This choice depends on the design of your model.
  • Insert data columns - should the data be placed in dynamically inserted columns, or should the data overwrite the existing columns? This choice depends on the design of your model.
  • Repeat grouped values - this is useful when you want to show values for every report column and row (as opposed to the normal report mode which leaves grouped row fields blank, rather than repeat them).
  • Show the query description - choose whether the query description should be shown when running the model.

Once you completed the query definition, a special function will be inserted into the current cell: =QUERY(ID, range), where ID is the query number, and range is the cell range into which the query data will be inserted. The function shows the description of the query.

After every change, the preview of the query results is automatically refreshed, which helps to integrate the query into your model.

Reports

The cell that contains the =QUERY(ID, range) function indicates where the query data will be dynamically inserted during Run model:

screenshot define models queries anatomy

The 3 rows below the placeholder are templates for the actual query data:

Headers - the query column headers will be placed on this row.

Data rows - the query rows with data. Dependent on the options that you selected:

  • the data will be placed into dynamically inserted rows (✭) in your model, or:
  • the data will be copied over the existing rows.

✭ The default setting is to Insert rows, enabling you to place additional content in your model underneath the query. Everything will be shifted down when the data rows are inserted, and all formula references will be adjusted accordingly. Cell values on columns adjacent to the query range (i.e. to the left and to the right of the query) will be copied down.

Totals row - the query report totals will be placed on this row.

You can set the cell styles (i.e. font, size, cell format, colors, borders etc.) for each of the 3 template rows. If left blank, default cell styles will be applied.

During Run model, realtime data will be inserted and the above template produces the following result:

screenshot define models analyze

Functions

You can use functions to pull selected data from report or data queries into individual cells. Unlike report queries, which insert an entire formatted report into a range of cells in the model, functions enable you to insert a single value or an aggregate total (e.g. a sum or count) into one cell. You can create as many functions as you want, to populate multiple cells with varied data:

screenshot define models queries functions

The example in this screenshot retrieves the sum of column 5 of query ID 1 for all rows where column 2 = "30. Revenue": =DSUM("30. Revenue", 1, 5, 2). The correct result is 240.436.

There is a collection of query functions that you can choose from. All query functions require the same parameters between brackets:

  • The 1st parameter is the value or cell reference that you want lookup in the query data.
  • The 2nd parameter is the ID of a report or data query. You can define queries within your model, and once defined the ID of a query is shown in the dropdown list in the query preview.
  • The 3rd and 4th parameters are optional: By default, all functions assume that column 1 in the query data contains the key value, and that column 2 contains the values that you want to retrieve. You only need to give the column numbers for the values and key as a parameter when different from these defaults.

Cell objects

Cell objects are definitions that you can place in a cell in a model to create advanced functionality within that cell, for example cell editors, buttons with row actions, conditional formats, sparklines, images, or hyperlinks.

To add cell objects, you need to select a cell or range of cells, and click one of these buttons in the toolbar:

screenshot define models objects

You can choose from 6 types of objects:

  • Cell editor - create editable cells (use this to build planning models).
  • Row actions - buttons to insert and delete rows (use this to build planning models).
  • Conditional formats - set different cell formats dependent on certain conditions.
  • Sparkline - include a small chart in a cell, showing the values in a range of cells.
  • Image - include an image in a cell. You can either specify a URL-based image file or you can choose from a large collection of small icons, called FontAwesome.
  • Web link - include a URL-based hyperlink in a cell.

Once you click the toolbar icon, a popup window will guide you through the process of defining the object.

Planning models

By default, models are read-only in Run model (i.e. all cells will be locked). This is the default setting for reporting models.

But you can also create planning models that allow users to enter and edit information into the model during Run model. Creating this type of models requires 2 or 3 additional steps:

  1. Add cell editors in cells.
  2. Add row actions in cells (optional).
  3. Add a Save query to the model.

Cell editors

Cell editors are definitions that you can place in a cell (or in a cell range) to make a cell editable (remember: by default, all cells are locked) and define both the type of cell value and the method by which users will be able to enter or select cell values.

To add cell editors, you need to select a cell or range of cells, and click this button in the toolbar:

screenshot define models objects

And then select the appropriate cell editor:

screenshot define models editors

You can choose from 8 types of editors:

  • Text - allow the user to enter any text.
  • Number - allow the user to enter numbers only.
  • Dropdown (list) - shows a dropdown, with the list of values referring to a cell range or a static list of values.
  • Dropdown (query) - shows a dropdown, with the list of values sourced from the database.
  • Dropdown (planner) - shows a dropdown, with a list of configurable planners.
  • Popup text - shows a popup into which the user can enter long text.
  • Date picker - shows a dropdown calendar from which the user can select a date.
  • Yes/No checkbox - shows a checkbox (use this in combination with the Yes/No cell format).

When you add a cell editor in a cell or range of cells, those cells are unlocked, and the user can enter or edit data in the model (and validated by the selected editor) during Run model.

Planners

Planners are configurable patterns that can be used to distribute amounts across a range of cells (for example, to apply a seasonal revenue pattern to a series of financial periods).

Adding planners to a model requires 2 steps:

  1. Create one or more Cell editors (Dropdown planner) - you can define multiple planners in each cell editor. A planner consists of a name and a numerical pattern.
  2. Enter one ore more PLANNER functions in cells, to populate cells with the required result for each index in the pattern.

The below example defines 3 patterns for a cell editor: 12 equal months, a 4-4-5 weeks calendar, and a seasonal pattern that trends upwards in the Summer:

screenshot define models editors planners

In addition to statically defined planners, you can also refer to a data query. Your data query can include multiple rows, with each row being treated as a separate planner. The first column on every row needs to contain the planner name, and the other columns need to contain the numeric patterns.

The absolute values of the numeric patterns are irrelevant, what matters is each relative value as a proportion of the sum of all values. You can define as many indices in the patterns as you need.

The PLANNER function returns a proportion of data according to the selected planner and the selected index. The returned value is calculated as follows:

data * value of given planner index / sum of all planner values

If the given index does not exist in the planner, the function will use the given ratio (which can be a cell reference, a formula, or a given value) and will return the result of data * ratio.

If neither the index or a ratio exists, the function will return 0 (zero).

PLANNER(data, planner, index, ratio)

Examples:
PLANNER(1000, "EqualMonths", 6) = 83.33 (1000 * 1 / 12
PLANNER(1000, "Weeks445", 6) = 96.15 (1000 * 5 / 52)
PLANNER(1000, "Summmer", 6) = 111.11 (1000 * 4 / 36)
PLANNER(1000, "", 0, B3/C3) = 200.00 (1000 * 1/10, assuming B3=1 and C3=10)

Row actions

Row actions are are configurable buttons that you can place in a cell in a model to allow rows to be inserted, copied, or deleted.

To add row actions, you need to select a cell or range of cells, and click this button in the toolbar:

screenshot define models objects

And then select the actions you want to enable:

screenshot define models row actions

This option enables you to define precisely where rows can be inserted, copied, or deleted in the model during Run model. Typically you would only enable this in the data entry section of your model.

Once created, you can call the row actions by clicking on one of the icons. Row actions are only active in Run models.

Save queries

By creating a save query in your model, you can save information back into a data set.

For every save query, you can select how new data should be imported into the data set:

  • Add to - add new data to the existing content of the data set.
  • Overwrite - overwrite the entire existing content of the data set.
  • Replace in - selectively replace existing content of the data set. For example, anytime you import a certain financial period, you might want to overwrite the previous content for that same period. If you select this option, you also need to indicate which column(s) will trigger the replacement. Read more here.
  • Update in - update the given columns in existing rows in the data set. This option will only update rows that already exist in the data set, and ignore any other data in the import source. The target data set must have a defined Key column, because that is used to determine whether a given row already exists or not.
  • Upsert in - update the given columns in existing rows in the data set, and insert rows that don't yet exist in the data set. The target data set must have a defined Key column, because that is used to determine whether a given row already exists or not.
  • Delete from - selectively delete existing content from the data set. Data that matches your data source will be deleted. No new data will be imported. If you select this option, you also need to indicate which column(s) will trigger the deletion. Read more here.

Once you have added a save query to a model, a Save button will automatically be added to the Run models screen, and the user can enter and edit data (in cells where you have created the above cell editors) and click the Save button when done.

XLReporting expects the row below your query to contain columns headers, and you can specify how many rows of data you want to import. If you combine save queries with report queries, the number of rows is automatically expanded based on the results of the report query.

For each column in your target data set, you can either select the relevant column in your model, a static value, or a function. You can also transpose columns into rows, convert the data, and filter the data. It works in the same way as Define imports.

When saving, XLReporting will try to process every row it encounters, up until the number of rows you have specified.

The option when empty values enables you to either skip entire rows when a field is empty, or repeat the values from the previous row (which is useful if your model data is grouped).

screenshot define models queries save

Actions

When defining a model, you can use the Save and Actions buttons in the right-top of the screen:

screenshot define models actions

These buttons enable you to do the following:

  • Save - save your changes
  • Actions - open a dropdown menu with further options:
    • Create a new model (or copy one)
    • Delete this model
    • Add to my dashboard
    • Export data or print
    • Review this model
    • Run this model now

Add to dashboard

A dashboard is a personal page with your own favorite reports and models. You can create multiple dashboards, and each dashboard can contain multiple reports or models.

Click on Actions - Add to my dashboard to add this model to either a new dashboard, or to a new dashboard:

screenshot dashboard models edit

Review this model

Click on Actions - Review this model to review a number of aspects of this model and its currently selected query:

  • Data diagram - shows a diagram with all linked data sets. This is derived from columns that are set to data type Linked values.
  • Linked data - shows the results of checks on the Key values and Linked values that are used to link data sets. Because linked values need to correspond with key values, this integrity check is important.
  • Define fields - shows a summary of all defined columns and data types.
  • Data set use - shows all linked data sets, the imports, reports, and models that are using this data set, and the total number of data rows in this data set.
  • Recent activity - show all recent user activity relating to this data set.

screenshot define models datasets review

Recommended reading:
Back to top | Data sets