GENERATESERIES in DAX: Create Continuous Number Ranges
In this article, we will learn how to use GENERATESERIES in DAX to create a continuous range of numbers and generate a sequence with a custom step value.
This function is useful when you need to dynamically generate numeric series for analysis, calculations, and other DAX table expressions.
📥 Practice Data:
Download Practice Data Free
🎥 Prefer learning through video?
DAX YouTube Playlist
What Is GENERATESERIES in DAX?
GENERATESERIES is a DAX function used to generate a table containing a sequence of numbers.
You can specify a starting value, an ending value, and optionally a step value.
The basic syntax is:
GENERATESERIES(
<StartValue>,
<EndValue>,
[<StepValue>]
)
The StepValue is optional. If you do not specify it, DAX uses a default step of 1.
1. Create a Continuous Range
Let’s start by creating a simple sequence of numbers from 1 to 12.
Query
// Generate
// 1. Create Continuous Range
EVALUATE
GENERATESERIES(1, 12)
Step-by-step explanation
Step 1: EVALUATE
EVALUATE is used to return the result of a table expression.
Since GENERATESERIES returns a table, we use it with EVALUATE.
Step 2: GENERATESERIES
GENERATESERIES(1, 12) tells DAX to generate a sequence starting from 1 and ending at 12.
Step 3: Default Step Value
Since we have not specified a third argument, DAX automatically increments the value by 1.
What will you get?
The query generates a single-column table containing the numbers from 1 through 12.
| Value |
|---|
| 1 |
| 2 |
| 3 |
| 4 |
| 5 |
| 6 |
| 7 |
| 8 |
| 9 |
| 10 |
| 11 |
| 12 |
When the step value is not specified, GENERATESERIES increments the values by 1.
2. Create a Range with Custom Steps
We can also control how much the value should increase between each row by specifying a third argument.
Query
// 2. Create Range with Custom Steps
EVALUATE
GENERATESERIES(1, 52, 2)
Step-by-step explanation
Step 1: Start Value
The first argument, 1, specifies where the sequence should begin.
Step 2: End Value
The second argument, 52, specifies the maximum value up to which the sequence should be generated.
Step 3: Step Value
The third argument, 2, tells DAX to increase the value by 2 for every row.
What will you get?
The generated sequence will contain odd numbers starting from 1 and continuing up to 51.
| Value |
|---|
| 1 |
| 3 |
| 5 |
| 7 |
| 9 |
| … |
| 47 |
| 49 |
| 51 |
Notice that 52 is not included because the sequence progresses in steps of 2:
1, 3, 5, 7, …, 49, 51.
The third argument of GENERATESERIES controls the interval between consecutive values.
Understanding the GENERATESERIES Arguments
| Argument | Example | Purpose |
|---|---|---|
| Start Value | 1 | Specifies where the sequence starts |
| End Value | 52 | Specifies the upper limit of the sequence |
| Step Value | 2 | Specifies how much the value increases between rows |
Comparing the Two Queries
| Query | Generated Sequence |
|---|---|
| GENERATESERIES(1, 12) | 1, 2, 3, 4, …, 11, 12 |
| GENERATESERIES(1, 52, 2) | 1, 3, 5, 7, …, 49, 51 |
Important Notes
1. GENERATESERIES returns a table
GENERATESERIES returns a table containing a single column of generated values.
Therefore, it can be used wherever a table expression is expected.
2. The step value is optional
If you omit the third argument, the sequence increases by 1.
3. Custom steps give you more control
By specifying a step value, you can generate sequences such as every 2nd number, every 5th number, or any other appropriate interval.
4. The ending value depends on the sequence
The generated series continues according to the specified step value and does not necessarily include the exact ending value.
For example, GENERATESERIES(1, 52, 2) ends at 51.
📝 Practice Exercise
Try creating the following sequences using GENERATESERIES:
- Create numbers from 1 to 100 with a step of 5.
- Create numbers from 10 to 50 with a step of 10.
- Create numbers from 0 to 1 with a step of 0.1.
Example
EVALUATE
GENERATESERIES(10, 50, 10)
This generates the sequence:
10, 20, 30, 40, 50.
Conclusion
In this article, we learned how to use GENERATESERIES to dynamically generate numeric sequences in DAX.
- GENERATESERIES creates a table containing a sequence of values.
- The first argument defines the starting value.
- The second argument defines the ending value.
- The optional third argument defines the step value.
- When the step value is omitted, the default increment is 1.
GENERATESERIES is a useful table-generating function for creating numeric ranges dynamically and can become especially powerful when combined with other DAX table functions.
📥 Practice Data:
Download Practice Data Free
🎥 Prefer learning through video?
DAX YouTube Playlist