Articles in this section
Category / Section

Using generate_series() Function in Bold BI with PostgreSQL

Published:

Introduction

When working with Bold BI, there may be scenarios where you need to generate a series of numbers for use in expressions or parameters. The generate_series() SQL function is a powerful tool that can help you create a set of sequential numbers, which can be particularly useful for creating reports or dashboards that require dynamic data ranges.

Applicability

The generate_series() function is specifically applicable when the Bold BI data store database is PostgreSQL or when using the PostgreSQL live connector. It is important to note that the syntax for generate_series() may differ if you are using other database connectors.

Syntax and Usage

The basic syntax for the generate_series() function in a PostgreSQL environment is as follows:

SELECT generate_series(start, stop, step);
  • start: The beginning value of the series.
  • stop: The ending value of the series.
  • step: The interval between each number in the series.

For example, if you want to generate a series of numbers from 1 to 10, you would use:

SELECT generate_series(1, 10);

This will produce a set of numbers from 1 to 10 with a default step of 1.

If you want to specify a different interval, for example, to generate every second number between 1 and 10, you would use:

SELECT generate_series(1, 10, 2);

This will produce a series of numbers: 1, 3, 5, 7, 9.

Practical Applications

The generate_series() function can be used in various scenarios within Bold BI, such as:

  • Creating date ranges for reports.
  • Generating a sequence of time slots for scheduling.
  • Producing a list of numbers for pagination purposes.
  • Filling in gaps in data for charting or analysis.

Additional References

Was this article useful?
Like
Dislike
Help us improve this page
Please provide feedback or comments
SM
Written by Siranjeevi Murugan
Updated
Comments (0)
Please  to leave a comment
Access denied
Access denied