Create Dataset

Prev Next

Creating a Dataset in reports is essential because it acts as the semantic layer between raw database tables and user‑facing reports, enabling reusable metrics, calculated columns, and flexible visualizations without altering the source database.

Note

Do not use a Physical Dataset directly to create custom reports or charts. Instead, create a Virtual Dataset with only the required fields, calculations, and aliases. This prevents unnecessary fields from appearing in drill-down views and keeps the report focused and easier to interpret.

Before creating reports, datasets must be configured and the supported dataset types are:

Virtual Dataset

A Virtual Dataset is a dataset created from a custom SQL query rather than directly mapping to a physical table or view in the database.

Example

Suppose you want to analyze Incident Records linked with Change Requests:

  • A physical dataset would only give you data from incident_records or change_requests.

  • A virtual dataset could be created with a SQL query joining both tables:

    SELECT i.incident_id, i.priority, c.change_id, c.status
    FROM incident_records i
    JOIN change_requests c ON i.change_ref = c.change_id;


    This query can be saved in SQL Lab and converted into a Virtual Dataset, enabling dashboards that show incident–change correlations.

Prerequisites

The required guidelines to ensure the dataset supports row-level security, naming standards, and time zone handling.

Required columns

Include the following columns in every virtual dataset. The column names must match exactly.

Column

Description

tenant_id

Identifies the tenant associated with the record.

assigned_workgroup_id

Identifies the workgroup assigned to the record.

location_id

Identifies the location associated with the record.

customer_id

Identifies the customer associated with the record.

These columns are required to implement Row-Level Security (RLS), which restricts report data based on the user's assigned permissions. After you save the dataset, it is available on the Dataset List page.

Dataset naming convention

When you save a custom query as a dataset, use the following naming convention:

mart_<module_code>_custom_<functional_name>

Placeholder

Description

module_code

Specifies the module code for the dataset.

custom

Indicates that the dataset is a custom dataset.

functional_name

Specifies a descriptive name that identifies the dataset.

Example

mart_im_custom_customer_ticket_sla_details.

Use a meaningful functional name so that the purpose of the dataset can be easily identified. After creating the dataset, you can edit it to create calculated fields, configure column properties, and add or update the dataset description.

Create Virtual Dataset

To create a Virtual Dataset, perform the following steps:

  1. Navigate to Reports > Custom widget > SQL > SQL Lab.
    The SQL page is displayed.

    Figure: SQL

  2. Enter the required details as described in the following table.

    Field

    Description

    Database

    Select or enter the connected data source. The connected data source in reports where the SQL query will run. You must select the database against which your virtual dataset query will be executed.

    Schema

    The logical namespace inside the selected database that contains tables and views. Choosing the schema ensures your SQL query references the correct objects.

    Table Schema

    Select the table name from the list for creating a virtual dataset, the reports uses the schema context to validate and execute the query

  3. Select the required table(s) to view their columns and structure and in the Query Editor window on the right, write your SQL query using the selected table(s).


    Figure: SQL Query

  4. Click Run the query to validate syntax and preview results.

Physical Dataset

A Physical Dataset is a dataset that directly maps to an existing database table or view. It is essentially a registered reference to a physical object in your connected database.

Example

Suppose you have a table incident_records in Database. Registering this table as a Dataset makes it a Physical Dataset. You can then define calculated columns (e.g., CASE WHEN status='Closed' THEN 1 ELSE 0 END) and reusable metrics (e.g., COUNT(incident_id)) on top of it.

To create a Physical Dataset, perform the following steps:

  1. Navigate to Reports > Custom widget > Datasets.
    The Datasets page is displayed.

    Figure: Datasets

  2. Click + Dataset to create a new Dataset.
    The New dataset page is displayed.

    Figure: New dataset

  3. Enter the required details as described in the following table and click Create and explore dataset.

    Field

    Description

    Database

    Select or enter the connected data source. The selected data source identifies which database is pulling tables or views from.

    Schema

    The logical namespace inside the database that organizes tables and views. When a database is selected, its default schema is automatically applied. The schema helps Superset locate the correct table for dataset creation.

    Table

    Select or enter the physical table or view in the selected schema. Automatically reads the table’s columns and datatypes when registered. Selecting a table registers it as a physical dataset.


    The list of the configured table is displayed.

    Figure: Table list

Identifying the Table Name

Tables in the mart follow a defined naming convention:

Table

Name

Static tables

Mart_<module code>_<functional name>

Custom attribute tables

Mart_<module code>_customattributes_sv

Multi‑valued custom attribute tables

Mart_<module code>_customattributes_mv

Module Name

Module Code

Incident

im

Service Request

sr

Knowledge Master

km

Change Management

cm

Problem Management

pm

Workorder

wo

CMDB

cmdb

Admin

adm

Asset Management

am

Custom Attributes

Custom attributes are additional fields associated with records such as incidents, service requests, problems, changes, and configuration items (CIs). In Custom Attributes are stored in module-specific mart tables ending in customattributes_sv.

The current table structure stores one row per record and custom attribute. This structure supports reporting on environments with large numbers of records and custom attributes.

Understand the Custom Attributes Table Structure

The custom attributes mart table uses a long-table structure.

  • One row per record and custom attribute: Each row represents a custom attribute associated with a record.

  • Attribute name: The attribute_name column identifies the custom field, such as Department or Policy No.

  • Attribute value: The attributevalue column stores the readable value of the custom field.

Previous and Current Table Structures

Feature

Previous wide structure

Current long structure

Row structure

One row per ticket

One row per ticket and custom attribute

Custom attribute storage

Each custom attribute has a separate column

Custom attributes are stored in attribute_name and attributevalue columns

Column names

May vary by customer environment

Uses a consistent set of columns

Suitable for

Environments with fewer custom attributes

Environments with many custom attributes and large record volumes

The previous wide structure could become difficult to maintain and could affect data loading and report performance when the number of custom attributes increased significantly.

Understand the Custom Attributes Mart Table Columns

The mart_im_customattributes_sv table stores incident custom attribute data.

Column

Description

uid

Unique identifier for the row.

ticket_id

Identifier of the incident ticket.

attributeid

Identifier of the custom attribute definition.

attribute_name

Display name of the custom attribute.

attributevalue

Readable value of the custom attribute.

include_time_stamp

Indicates whether a timestamp applies to the value.

recorded_on

Date and time when the row was loaded for reporting.

updated_time

Date and time when the row was last updated.

is_record_active

Indicates whether the row is active for reporting.

Filter Custom Attribute Data

Use the attribute_name column to retrieve a specific custom attribute. Use the record ID column to retrieve attributes associated with a specific record.

Examples:

  • To retrieve Department values, filter by attribute_name = 'Department'.

  • To retrieve custom attributes for a specific incident, filter by ticket_id.

  • To retrieve incident details along with custom attribute values, join the custom attributes mart table with the incident master table using ticket_id.

Create a Report Using Custom Attributes

To create a report with selected custom attributes, create a virtual dataset in SQL Lab using the relevant custom attributes mart table.

Use the following SQL expression to display a custom attribute as a column:

MAX(
    CASE
        WHEN attribute_name = 'Department'
        THEN attributevalue
    END
) AS Department

Replace Department with the exact custom attribute name configured in your environment. Replace the alias after AS with the required report column label.

Create a Report with Multiple Custom Attributes

Use the following example to display Department, Policy No., and Is FLA Done for each incident.

SELECT
    ticket_id,
    MAX(CASE
        WHEN attribute_name = 'Department'
        THEN attributevalue
    END) AS Department,
    MAX(CASE
        WHEN attribute_name = 'Policy No.'
        THEN attributevalue
    END) AS `Policy No.`,
    MAX(CASE
        WHEN attribute_name = 'Is FLA Done'
        THEN attributevalue
    END) AS `Is FLA Done`
FROM mart_im_customattributes_sv
WHERE LOWER(IFNULL(is_record_active, 'true')) = 'true'
GROUP BY ticket_id;

This query groups the custom attribute values by incident ticket and displays each selected attribute as a separate report column.

To add another custom attribute, add a MAX(CASE WHEN attribute_name = ... THEN attributevalue END) expression to the SELECT list. Use the exact attribute name and specify the required column alias. Include only the custom attributes required for the report. You do not need to include every custom attribute defined in the application.

Note

The source document uses active in its sample SQL queries but lists is_record_active in the current table structure. Confirm the correct active-record column name in your reporting environment before using the query.

Use Custom Attributes in Other ITSM Modules

The long-table structure is also used for custom attributes in Service Request, Problem Management, Change Management, CMDB, and other supported modules.

Use the appropriate module-specific table and record ID when creating a report. The record ID may differ by module; for example, the incident table uses ticket_id.

Best Practise

  • Select only the required attributes. Include only the fields needed for the report.

  • Use exact attribute names. Ensure that each value used in attribute_name matches the configured name in your environment.

  • Group data by the record ID. Use the appropriate record ID to display selected custom attributes for each record.

  • Filter active records when required. Use the correct active-record column for your environment.

  • Reuse datasets where appropriate. Use an existing dataset when it meets the requirements of multiple reports or charts.