如何处理 PowerBI 自定义数据连接器中缺失的字段?
How to handle missing fields in a PowerBI custom data connector?
我正在尝试通过 returns 一组分页记录(类似于 OData nextLink 模式)的 REST Web 服务创建自定义 PowerBI 连接器。对于没有值的字段,该服务会忽略空值,因此某些记录的字段可能比其他记录多或少。
例如,我可能会回来:
{
"count": 2,
"next_link": "...",
"value": [
{
"first": "John",
"last": "Doe"
},
{
"first": "Jame",
"middle": "S",
"last": "Doe"
}
]
}
我已经从 DataConnectors TripPin repo 实现了分页机制(使用辅助函数 Table.GenerateByPage),但是当我查看记录列表时,我发现缺少字段的行有错误。
错误的形式是:
Expression.Error: The field 'middle' of the record wasn't found.
Details:
first=Jane
last=Doe
根据 docs: "the columns and table type of the combined table (i.e. all pages together) are derived from the first page of data." 但在上面的示例中,数据的第一页包含一条没有 "middle" 名称字段的记录。
我明白这个错误,但我不确定如何在我的数据连接器中处理这个错误。
我希望 PowerBI 中生成的 Table 对任何缺失值使用 "null"。如何修改 Table.GenerateByPage 以对任何缺失字段使用 null 来规范化串联列表?还是有更好的方式来处理此类数据?
您需要按照 TripPin 系列教程中的第 7 篇对数据强制实施架构:https://github.com/Microsoft/DataConnectors/tree/master/samples/TripPin/7-AdvancedSchema
这确实有效 - 我最近在此处的通用 REST API 上实现了 Microsoft 的示例:https://github.com/GrantQuick/BlackbaudSkyApi
我正在尝试通过 returns 一组分页记录(类似于 OData nextLink 模式)的 REST Web 服务创建自定义 PowerBI 连接器。对于没有值的字段,该服务会忽略空值,因此某些记录的字段可能比其他记录多或少。
例如,我可能会回来:
{
"count": 2,
"next_link": "...",
"value": [
{
"first": "John",
"last": "Doe"
},
{
"first": "Jame",
"middle": "S",
"last": "Doe"
}
]
}
我已经从 DataConnectors TripPin repo 实现了分页机制(使用辅助函数 Table.GenerateByPage),但是当我查看记录列表时,我发现缺少字段的行有错误。 错误的形式是:
Expression.Error: The field 'middle' of the record wasn't found.
Details:
first=Jane
last=Doe
根据 docs: "the columns and table type of the combined table (i.e. all pages together) are derived from the first page of data." 但在上面的示例中,数据的第一页包含一条没有 "middle" 名称字段的记录。
我明白这个错误,但我不确定如何在我的数据连接器中处理这个错误。 我希望 PowerBI 中生成的 Table 对任何缺失值使用 "null"。如何修改 Table.GenerateByPage 以对任何缺失字段使用 null 来规范化串联列表?还是有更好的方式来处理此类数据?
您需要按照 TripPin 系列教程中的第 7 篇对数据强制实施架构:https://github.com/Microsoft/DataConnectors/tree/master/samples/TripPin/7-AdvancedSchema
这确实有效 - 我最近在此处的通用 REST API 上实现了 Microsoft 的示例:https://github.com/GrantQuick/BlackbaudSkyApi