Home > Back-end >  GENERATESERIES() in half hour increments
GENERATESERIES() in half hour increments

Time:10-16

I'm using the below DAX code to create a date time table, however, I am trying to increment every half hour but I am unsure of how to go about this.

DateTime = 
ADDCOLUMNS (
    CROSSJOIN (
        CALENDAR(DATE(2021,01,01),DATE(2021,01,01)),
        SELECTCOLUMNS(GENERATESERIES(0,23,1),"Time",TIME([Value],0,0))
    ),
    "DateTime", [Date]   [Time]
)

enter image description here

CodePudding user response:

You could modify what you have like this:

DateTime = 
ADDCOLUMNS (
    CROSSJOIN (
        CALENDAR(DATE(2021,01,01),DATE(2021,01,01)),
        SELECTCOLUMNS(GENERATESERIES(0,23.5,.5),"Time",TIME([Value],([value]-INT([value]))*60,0))
    ),
    "DateTime", [Date]   [Time]
)

CodePudding user response:

You could do this

SELECTCOLUMNS ( GENERATESERIES ( 0, 47, 1 ), "Time", [Value] / 48 )

and then convert the data type for the Time column to Time.

CodePudding user response:

You almost got it, but consider that a minute is just 1/1440 of a day

DateTime = 
ADDCOLUMNS(
    CROSSJOIN(
        CALENDAR( DATE( 2021, 1, 1), DATE( 2021, 12, 31)),
        DATATABLE("Minutes", INTEGER,{{0}, {30}})
    ),
    "DateTime", [Date]   [Minutes] / (24 * 60)
)
  • Related