Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
MarkH
Helper I
Helper I

weird datetime format change in the middle of the data

Given the following dax table, all dates in GB format,

 

Time - DST2 =
ADDCOLUMNS(
    ADDCOLUMNS(
    GENERATESERIES(
        DATE(2024, 1, 1), // Start date (January 1, 2024)
        DATE(2026, 12, 31), // End date (December 31, 2025)
        Time(1, 0, 0) // 1-hour increment (h,m,s)
    ),

    "BST",[Value]+(1/24) //value has been renamed the GMT column

,"StartSunday",
    VAR d = DATE( YEAR([Value]), 3, 1)  // Assuming March as an example
    VAR r = EOMONTH( d, 0 ) - MOD( WEEKDAY( EOMONTH( d, 0 ), 2 ), 7 )
    RETURN r

,"FinishSunday",
    VAR d = DATE( YEAR([Value]), 10, 1)  // Assuming March as an example
    VAR r = EOMONTH( d, 0 ) - MOD( WEEKDAY( EOMONTH( d, 0 ), 2 ), 7 )
    RETURN r
    ), //end of addcolumns
"DST",
    if([StartSunday]<[Value] && [FinishSunday]>[Value],"BST","GMT")
) //end of addcolumns
 
why does the format of the Value column suddenly change from 27/11/2024 09:00:00 to the next row being 27/11/2024 09:59:59 when I am expecting it to return 27/11/2024 10:00:00?
 

 

 

1 ACCEPTED SOLUTION
OwenAuger
Super User
Super User

Hi @MarkH 

The short answer is that when using TIME(1,0,0) as the increment in GENERATESERIES, some numerical error is introduced since the values are converted to floating point in the course of the repeated summation.

 

Here's one way you could rewrite to get around this issue, with some variables added for clarity

(this will end at 23:00 rather than 0:00 on the last date though):

 

Time - DST2 =
VAR TimeValues =
    SELECTCOLUMNS ( GENERATESERIES ( 0, 23 ), "@Time", TIME ( [Value], 0, 0 ) )
VAR DateValues =
    GENERATESERIES (
    	DATE ( 2024, 1, 1 ), // Start date (January 1, 2024)
	    DATE ( 2026, 12, 31 ) // End date (December 31, 2025)
	)
VAR DateTimeValues =
    SELECTCOLUMNS (
        GENERATE (
            DateValues,
            TimeValues -- 0:00 to 23:00
        ),
        "Value", [Value] + [@Time]
    )
RETURN
    ADDCOLUMNS (
        ADDCOLUMNS (
			DateTimeValues,
            "BST",
                [Value] + ( 1 / 24 ) //value has been renamed the GMT column
                ,
            "StartSunday",
                VAR d =
                    DATE ( YEAR ( [Value] ), 3, 1 ) // Assuming March as an example
                VAR r =
                    EOMONTH ( d, 0 ) - MOD ( WEEKDAY ( EOMONTH ( d, 0 ), 2 ), 7 )
                RETURN
                    r,
            "FinishSunday",
                VAR d =
                    DATE ( YEAR ( [Value] ), 10, 1 ) // Assuming March as an example
                VAR r =
                    EOMONTH ( d, 0 ) - MOD ( WEEKDAY ( EOMONTH ( d, 0 ), 2 ), 7 )
                RETURN
                    r
        ),
        //end of addcolumns
        "DST",
            IF ( [StartSunday] < [Value] && [FinishSunday] > [Value], "BST", "GMT" )
    )
//end of addcolumns

 

Note: CROSSJOIN could also be used in place of GENERATE here.

 

Does this work for you?


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

View solution in original post

1 REPLY 1
OwenAuger
Super User
Super User

Hi @MarkH 

The short answer is that when using TIME(1,0,0) as the increment in GENERATESERIES, some numerical error is introduced since the values are converted to floating point in the course of the repeated summation.

 

Here's one way you could rewrite to get around this issue, with some variables added for clarity

(this will end at 23:00 rather than 0:00 on the last date though):

 

Time - DST2 =
VAR TimeValues =
    SELECTCOLUMNS ( GENERATESERIES ( 0, 23 ), "@Time", TIME ( [Value], 0, 0 ) )
VAR DateValues =
    GENERATESERIES (
    	DATE ( 2024, 1, 1 ), // Start date (January 1, 2024)
	    DATE ( 2026, 12, 31 ) // End date (December 31, 2025)
	)
VAR DateTimeValues =
    SELECTCOLUMNS (
        GENERATE (
            DateValues,
            TimeValues -- 0:00 to 23:00
        ),
        "Value", [Value] + [@Time]
    )
RETURN
    ADDCOLUMNS (
        ADDCOLUMNS (
			DateTimeValues,
            "BST",
                [Value] + ( 1 / 24 ) //value has been renamed the GMT column
                ,
            "StartSunday",
                VAR d =
                    DATE ( YEAR ( [Value] ), 3, 1 ) // Assuming March as an example
                VAR r =
                    EOMONTH ( d, 0 ) - MOD ( WEEKDAY ( EOMONTH ( d, 0 ), 2 ), 7 )
                RETURN
                    r,
            "FinishSunday",
                VAR d =
                    DATE ( YEAR ( [Value] ), 10, 1 ) // Assuming March as an example
                VAR r =
                    EOMONTH ( d, 0 ) - MOD ( WEEKDAY ( EOMONTH ( d, 0 ), 2 ), 7 )
                RETURN
                    r
        ),
        //end of addcolumns
        "DST",
            IF ( [StartSunday] < [Value] && [FinishSunday] > [Value], "BST", "GMT" )
    )
//end of addcolumns

 

Note: CROSSJOIN could also be used in place of GENERATE here.

 

Does this work for you?


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.