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
arielcedola
Helper III
Helper III

Transforming values in column without creating new columns in M language

Hi,

I'm using m language to perform the following convertions of datetime data:

1) unix timestamp to utc date time zone

2) utc date time zone to local time zone

3) local time zone to datetime

The query I'm using is the following:

 

let

....

#"unix to utc" = Table.AddColumn(#"previous step", "timestamp_utc", each #datetimezone(1970,1,1,0,0,0,0,0) + #duration(0,0,0,[data])),
#"utc to local" = Table.AddColumn(#"unix to utc", "timestamp_local", each DateTimeZone.ToLocal([timestamp_utc])),
#"to datetime" = Table.AddColumn(#"utc to local", "timestamp", each DateTime.From([timestamp_local]))
in
#"to datetime"

 

Unix datetime data is in the column [data] of my table.

Every step in the query introduces a new column: timestamp_utc, timestamp_local and timestamp. My question is, how can I perform the same functions and get the same result as in the last column timestamp, but without introducing the intermediate columns timestamp_utc and timestamp_local?

Thanks .)

1 ACCEPTED SOLUTION
camargos88
Community Champion
Community Champion

Hi @arielcedola ,

 

Try nesting the functions:

 

Table.AddColumn(#"previous step", "timestamp_utc", each DateTime.From(DateTimeZone.ToLocal(#datetimezone(1970,1,1,0,0,0,0,0) + #duration(0,0,0,[data]))))

 

 



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



View solution in original post

2 REPLIES 2
camargos88
Community Champion
Community Champion

Hi @arielcedola ,

 

Try nesting the functions:

 

Table.AddColumn(#"previous step", "timestamp_utc", each DateTime.From(DateTimeZone.ToLocal(#datetimezone(1970,1,1,0,0,0,0,0) + #duration(0,0,0,[data]))))

 

 



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



Exactly! I tried nesting the functions before but for some reason it didn't work. Now it did it perfectly.

Thanks .)

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.

Top Solution Authors
Top Kudoed Authors