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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Daven
Helper II
Helper II

datetime year to fraction (3) format

Hi,

 

How do I adjust below measure if UTC is in datetime year to fraction (3) format? Need this as a measure as using directquery and unable to do any transformations to dataset

 

i.e UTC format:  2021-01-02T00:03:05.1330000

 

Local Time =
CONVERT (
FORMAT ( SELECTEDVALUE ( 'Table'[UTC] ), "MM/dd/YYYY" ) & " "
& REPLACE (
FORMAT ( SELECTEDVALUE ( 'Table'[UTC] ), "HH:MM:SS" ),
1,
2,
HOUR ( SELECTEDVALUE ( 'Table'[UTC] ) ) - 8
),
DATETIME
)

 

@v-yingjl

@UTC to Local as measure

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

Your "UTC"  timestamp isn't UTC. It's missing the Z at the end. Sloppy.

There is no need to do this as a measure.  Use a calculated column

 

timestamp = DATEVALUE(left(UTC[UTC],10))+TIMEVALUE(mid(UTC[UTC],12,8))
 
or better yet, do it in Power Query.

 

let
Source = Table.FromRows({{"2021-01-02T00:03:05.1330000"}},{"UTC"}),
#"Added Custom" = Table.AddColumn(Source, "timestamp", each DateTime.FromText([UTC]))
in
#"Added Custom"

 

 

View solution in original post

1 REPLY 1
lbendlin
Super User
Super User

Your "UTC"  timestamp isn't UTC. It's missing the Z at the end. Sloppy.

There is no need to do this as a measure.  Use a calculated column

 

timestamp = DATEVALUE(left(UTC[UTC],10))+TIMEVALUE(mid(UTC[UTC],12,8))
 
or better yet, do it in Power Query.

 

let
Source = Table.FromRows({{"2021-01-02T00:03:05.1330000"}},{"UTC"}),
#"Added Custom" = Table.AddColumn(Source, "timestamp", each DateTime.FromText([UTC]))
in
#"Added Custom"

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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