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
Anonymous
Not applicable

JSON datetime conversion in power query

Hi,

 

I am looking for 2 clear solutions.

 

1. Query for JSON string datetime conversion to datetime in PBI.

 

2. Can a ONE query be executed to convert multiple columns that are currently in JSON string datetime format ?

 

Thanks in advance for any solutions around this.

1 ACCEPTED SOLUTION

5 REPLIES 5
dax
Community Support
Community Support

Hi @Anonymous , 

If possible, could you please inform me more detailed information (such as your json sample and your expected output)? Then I will try to test this in my enviornment.

Please do mask sensitive data before uploading.

Thanks for your understanding and support.
Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

lbendlin
Super User
Super User

JSON doesn't have a standardized datetime string format. Are you talking about ISO-8601 ? Maybe show an example of your strings?

 

And yes, transforms can be applied to multiple columns at the same time.

Anonymous
Not applicable

Hi @lbendlin @dax 

 

Correct its ISO-8601

 

attached Screen shot of the data presented in Power BI

 

1592715600000

Equates to

06/21/2020 15:000:00

MM/DD/YYYY HRS:MIN:SEC

 

iv applied a few different queries but no luck as yet.Screen Shot 2020-06-23 at 21.56.59.png

dax
Community Support
Community Support

Hi @Anonymous , 

You could try @lbendlin 's suggestions and change it like below

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjS1NDI3NDUzAAGl2FgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [name = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"name", type number}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each #datetime(1970, 1, 1, 0, 0, 0) + #duration(0, 10, 0, [name]/1000)),
    #"Changed Type1" = Table.TransformColumnTypes(#"Added Custom",{{"Custom", type datetime}})
in
    #"Changed Type1"

Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Those are millisecond epochs.

 

You can use them as described here:

 

https://community.powerbi.com/t5/Desktop/Converting-UNIX-time-to-Date-in-PowerBI-for-Desktop/td-p/13...

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