Daily DAX : Day 431 GENERATESERIES
Power BI DAX Function: GENERATESERIES
Description
The GENERATESERIES function in DAX returns a single-column table containing an arithmetic sequence of values (numbers, dates, or times). The column is named "Value" by default.
It is commonly used to generate sequences for tables, parameters, or dynamic calculations.
Syntax
GENERATESERIES(, [, ])
Parameters
| Parameter | Description |
|---|---|
| The starting value of the series (required). | |
| The ending value of the series (required). The sequence includes values up to and including the last value ≤ endValue. | |
| The optional increment (step). Defaults to 1 if omitted. |
Return Value
A table with one column ("Value") containing the sequence. Returns an empty table if startValue > endValue.
Examples
- Basic integers:
GENERATESERIES(1, 5)
Returns: 1, 2, 3, 4, 5 - With increment:
GENERATESERIES(0, 10, 2)
Returns: 0, 2, 4, 6, 8, 10 - Decimals:
GENERATESERIES(1.2, 2.4, 0.4)
Returns: 1.2, 1.6, 2.0, 2.4 - Dates:
GENERATESERIES(DATE(2025, 1, 1), DATE(2025, 1, 5), 1)
Returns a sequence of dates from Jan 1 to Jan 5, 2025.
Common Use Cases
- What-If Parameters: Power BI uses it behind the scenes to create slicer-based parameter tables (e.g., discount rates from 0% to 20%).
- Creating Custom Tables: Generate a table of numbers, dates, or times for use as a dimension (e.g., a custom date table or number sequence).
- Dynamic Bins or Buckets: Create ranges for histograms or grouping data (e.g., age groups, sales tiers).
- Time Intelligence: Generate sequences for time-based calculations, like custom periods or depreciation schedules.
- Scenario Analysis: Test measures across a range of values (e.g., sensitivity analysis).
Notes
- Not supported in DirectQuery mode for calculated columns or row-level security.
- Can be used in calculated tables: Go to Modeling > New Table and enter the expression.
Comments
Post a Comment