Skip to content

Data Sources

CxReports allows you to connect to various data sources to retrieve data for use in your reports. This flexibility ensures that you can integrate data from APIs, JSON or CSV files, SQL databases, and even perform custom computations using JavaScript. Understanding how to set up and manage these data sources is crucial for creating dynamic and informative reports.

Overview of Data Sources

Data sources can be categorized into global or report-specific types:

  • Report-Specific Data Sources: These are tied to individual reports and are defined within the context of those reports.
  • Reusable Data Sources: Designed to be easily attached to multiple reports without the need to redefine them, enhancing efficiency and maintainability.
  • Global Data Sources: These are available across all reports within your application, allowing you to maintain consistency and reduce redundancy in data management.

To manage data sources, navigate to the Report tab in the ribbon and click on Data Sources. Here, you can view existing sources or add new ones.

Configuring Data Sources

When setting up a new data source, you need to specify several key attributes:

  • Name: A unique identifier for the data source. This name is used to reference the data within the $data object in your reports. For example, $data.people refers to data from a source named 'people'.
  • Display Name: A user-friendly name for the data source, making it easier to recognize in the interface.
  • Type: The type of data source (SQL, API, JSON, CSV, or JavaScript) determines the additional configuration options required.

SQL Data Sources

For SQL data sources, you must provide a SQL query to fetch data from your database. It's important to map any parameters used in your query to ensure they are handled correctly.

API Data Sources

API data sources fetch data from external APIs. Configure these by specifying the URL, choosing between GET or POST methods, and setting necessary headers and body content.

JavaScript Data Sources

JavaScript data sources are useful for computations, such as summing values or combining data from multiple sources. Here’s a basic template for a JavaScript data source:

($data, $params) => {
  let result = null;
  // perform calculations
  return result;

CSV and JSON Data Sources

These data sources are ideal for incorporating static data into your reports. Simply paste the CSV or JSON content directly and reference it within your report.


Data sources can depend on parameters or other data sources. Changes in any dependent element trigger the data source to reload, ensuring your report data is always up to date based on the latest inputs.

By effectively managing and configuring data sources, you can leverage the full power of CxReports to create dynamic, data-driven reports tailored to your needs.