GENERATESERIES DAX Function (Table manipulation)

Returns a table with one column, populated with sequential values from start to end.

Syntax

GENERATESERIES ( <StartValue>, <EndValue> [, <IncrementValue>] )
Parameter Attributes Description
StartValue

The start value of the column.

EndValue

The end value of the column.

IncrementValue Optional

The increment value of the column.

Return values

Table A table with a single column.

A single column table containing the values of an arithmetic series.
The name of the column is Value.

Remarks

When EndValue is less than StartValue, an empty table is returned.
IncrementValue must be a positive value.
The sequence stops at the last value that is less than or equal to EndValue.

Examples

This example uses GENERATE to create a table for time within a day with the minute granularity.

EVALUATE
//Time Dimension 
//Working Hours 9:00am to 5:00pm 
VAR Opening = 9
VAR Closing = 17
//Time Slot 
VAR TimeSlot = 30
VAR Offset = ( TimeSlot / 2 )
RETURN
    GENERATE (
        GENERATESERIES ( 0, 1439, 1 ),
        // 24 hours/day * 60 minutes/hour = 1,440 - 1 (initial time 12am) 
        VAR __Minutes = [Value]
        VAR __Time =
            TIME ( 0, __Minutes, 0 )
        // MROUND: Rounds Value to the nearest multiple of TimeSlot
        VAR __MinutesRounded =
            MROUND ( ( __Minutes + Offset ), TimeSlot )
        VAR __StartTimeSlotRounded =
            TIME ( 0, __MinutesRounded - TimeSlot, 0 )
        VAR __EndTimeSlotRounded =
            TIME ( 0, __MinutesRounded, 0 )
        RETURN
            ROW (
                    "Hour", HOUR ( __Time ),
                    "Minute", MINUTE ( __Time ),
                    "Hour Minute 24h", FORMAT ( __Time, "hh:mm" ),
                    "Hour Minute 12h", FORMAT ( __Time, "hh:mm AM/PM" ),
                    "30 Minute Slot Start", FORMAT ( __StartTimeSlotRounded, "hh:mm" ),
                    "30 Minute Slot End", FORMAT ( __EndTimeSlotRounded, "hh:mm" ),
                    "30 Minute Slot", FORMAT ( __StartTimeSlotRounded, "hh:mm" ) & "-"
                        & FORMAT ( __EndTimeSlotRounded, "hh:mm" ),
                    "Working Hours", IF (
                        ( __Minutes / 60 ) >= Opening
                            && ( __Minutes / 60 ) <= Closing,
                        "Yes",
                        "No"
                    ),
                    "Time", __Time,
                    "TimeSlot Start", __StartTimeSlotRounded,
                    "TimeSlot End", __EndTimeSlotRounded
            )
    )

Related articles

Learn more about GENERATESERIES in the following articles:

Last update: Jun 3, 2019   » Contribute   » Show contributors

Contributors: Alberto Ferrari, Marco Russo, Daniil Maslyuk, Naji El Kotob

MSDN documentation: https://docs.microsoft.com/en-us/dax/generateseries-function

DAX Conventions
Context Transition

This function performs a Context Transition if called in a Row Context. Click to read more.

Row Context

This expression is executed in a Row Context. Click to read more.

Iterator

Not recommended

The use of this function is not recommended. See Remarks and Related functions for alternatives.

Not recommended

The use of this parameter is not recommended.

Deprecated

This function is deprecated. Jump to the Alternatives section to see the function to use.

Deprecated

This parameter is deprecated and its use is not recommended.

Contribute

Want to improve the content of GENERATESERIES? Did you find any issue? Please, report it us!
All submissions will be evaluated for possible updates of the content.