azure - Power BI - Azure Cosmos DB 中的桌面日期时间

标签 azure azure-cosmosdb powerbi-desktop

我使用的是通过 Azure Cosmos .NET SDK 填充的 Azure Cosmos DB。根据文档,DateTimes 应存储为 ISO_8601 格式的序列化字符串( https://learn.microsoft.com/en-us/azure/cosmos-db/working-with-dates )。当我在 azure 门户或 azure 存储资源管理器应用中查看我的记录时,情况似乎就是这样。

enter image description here

您可以看到我的 StartTime 和 EndTime 属性以及时间戳的格式为“2019-07-15T16:24:51.392Z”

当我将数据导入 Power BI Desktop 时,该值显示为一些奇怪的字符串/数字。例如

00636988010188048801

我认为这可能是自 1970 年 1 月 1 日以来的毫秒数,但事实并非如此。有谁知道如何正确地将日期时间导入Power BI或如何将该值转换为日期时间?尝试将数据类型设置为任何不同的日期时间选项都会导致错误。

高级编辑器如下所示:

let
    Source = DocumentDB.Contents("https://myurl.documents.azure.com:443/"),
    TablesDB = Source{[id="TablesDB"]}[Collections],
    TablesDB_InstanceData = TablesDB{[db_id="TablesDB",id="InstanceData"]}[Documents],
    #"Expanded Document" = Table.ExpandRecordColumn(TablesDB_InstanceData, "Document", {"id", "RunId", "InstanceId", "StartTime", "EndTime", "MessagesProcessed", "IsCompareInstance", "_ts"}, {"id", "RunId", "InstanceId", "StartTime", "EndTime", "MessagesProcessed", "IsCompareInstance", "_ts"}),
    #"Expanded RunId" = Table.ExpandRecordColumn(#"Expanded Document", "RunId", {"$v"}, {"$v"}),
    #"Expanded InstanceId" = Table.ExpandRecordColumn(#"Expanded RunId", "InstanceId", {"$v"}, {"$v.1"}),
    #"Expanded StartTime" = Table.ExpandRecordColumn(#"Expanded InstanceId", "StartTime", {"$v"}, {"$v.2"}),
    #"Expanded EndTime" = Table.ExpandRecordColumn(#"Expanded StartTime", "EndTime", {"$v"}, {"$v.3"}),
    #"Expanded MessagesProcessed" = Table.ExpandRecordColumn(#"Expanded EndTime", "MessagesProcessed", {"$v"}, {"$v.4"}),
    #"Expanded IsCompareInstance" = Table.ExpandRecordColumn(#"Expanded MessagesProcessed", "IsCompareInstance", {"$v"}, {"$v.5"})
in
    #"Expanded IsCompareInstance"

最佳答案

当我将此作为问题发布到 Power BI 社区时,那里有人发布了处理此问题的方法:

let

ConvertTimestamp = (ts) => #datetime(1, 1, 1, 0, 0, 0) + #duration(0, 0, 0, ts / 10000000)

in

ConvertTimestamp(635912639960000000)

关于azure - Power BI - Azure Cosmos DB 中的桌面日期时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57813224/

相关文章:

powerbi - 如何在 power bi 中使用两个不同的切片

amazon-web-services - PowerBI Athena Beta 连接器详细信息 : "We cannot convert the value null to type Record."

azure - Cosmos DB 最终一致性最大上限

c# - 将数据保存到 DocumentDb 中的多个集合中

.net - 尝试在 Azure Publish 上验证图形客户端时出现异常 : "Failed to acquire token silently. Call method AcquireToken"

azure - 如何在 Azure Blob 存储上下载名称带有空格的文件?

node.js - 在 kubernetes 中使用 azure cosmos mongodb

powerbi - 如何在Power Bi中加载大图像

azure - 为什么 Azure 找不到我的 TFS 项目?

Azure管道从资源存储库读取文件