用 Csv.Document 截断的电源查询文本

Posted

技术标签:

【中文标题】用 Csv.Document 截断的电源查询文本【英文标题】:power query text truncated with Csv.Document 【发布时间】:2021-11-02 22:12:44 【问题描述】:

我正在 Power Query 编辑器(Excel 桌面)中加载 CSV 文件。 CSV 文件有 4 列。在 Power Query 编辑器中预览数据时,第 4 列的文本被截断。

有什么帮助或建议吗??

我尝试阅读一些参考资料。但没有什么对我有帮助。


参考文献

Chris Webb 的 BI 博客:Power BI 中文本值的最大长度是多少? Chris Webb 的 BI 博客 https://blog.crossjoin.co.uk/2019/05/17/maximum-length-text-value-power-bi/

从 .xsls 导入时,文本被截断为 255 个字符,而不是从 .csv 导入 https://social.technet.microsoft.com/Forums/windows/en-US/3a8bc142-019a-4e6e-b853-c3d4bfff1aea/text-truncated-to-255-characters-when-importing-from-xsls-but-not-from-csv?forum=powerquery

Csv.Document - PowerQuery M |微软文档 https://docs.microsoft.com/en-us/powerquery-m/csv-document

Chris Webb 的 BI 博客:深入了解 Csv.Document M 函数 Chris Webb 的 BI 博客 https://blog.crossjoin.co.uk/2018/03/09/an-in-depth-look-at-the-csv-document-m-function/


CSV_(txt_value)

字符数 = 1262

"""Id"":""3880a610-6c94-44aa-998c-f6c6b8ccbebc"",""RecordType"":20,""CreationTime"":""2021-09-20T20:54:27"",""Operation"":""ViewReport"",""OrganizationId"":""00293fd9-3450-49e6-a034-ce3920c8473f"",""UserType"":0,""UserKey"":""1003200110B822A2"",""Workload"":""PowerBI"",""UserId"":""brian.lofton@bisonok.com"",""ClientIP"":""97.114.98.165"",""UserAgent"":""Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (Khtml, like Gecko) Chrome\/93.0.4577.82 Safari\/537.36"",""Activity"":""ViewReport"",""ItemName"":""IT Spend Analysis Sample (RLS)"",""WorkSpaceName"":""DEMO 1 - ** TEST TEST **"",""DatasetName"":""IT Spend Analysis Sample (RLS)"",""ReportName"":""IT Spend Analysis Sample (RLS)"",""CapacityId"":""2C378C41-B989-4998-9FF8-046798A3572C"",""CapacityName"":""Premium Per User - Reserved"",""WorkspaceId"":""814483ee-dc75-47be-a379-db0efe658fb6"",""ObjectId"":""IT Spend Analysis Sample (RLS)"",""DatasetId"":""4506dbe0-5ecf-47f9-85a9-73ff278bca3f"",""ReportId"":""18d7271e-fb14-425c-a17b-a2ce4866dd48"",""IsSuccess"":true,""ReportType"":""PowerBIReport"",""RequestId"":""4073f095-fbb0-94bc-b05d-bffba3ec3566"",""ActivityId"":""bf26238f-4dd0-86c5-620c-20ab29c1704c"",""DistributionMethod"":""Workspace"",""ConsumptionMethod"":""Power BI Web"""

PowerQuery_(txt_value):

字符数 = 1119

"""Id"":""3880a610-6c94-44aa-998c-f6c6b8ccbebc"",""RecordType"":20,""CreationTime"":""2021-09-20T20:54:27"",""Operation"":""ViewReport"",""OrganizationId"":""00293fd9-3450-49e6-a034-ce3920c8473f"",""UserType"":0,""UserKey"":""1003200110B822A2"",""Workload"":""PowerBI"",""UserId"":""brian.lofton@bisonok.com"",""ClientIP"":""97.114.98.165"",""UserAgent"":""Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/93.0.4577.82 Safari\/537.36"",""Activity"":""ViewReport"",""ItemName"":""IT Spend Analysis Sample (RLS)"",""WorkSpaceName"":""DEMO 1 - ** TEST TEST **"",""DatasetName"":""IT Spend Analysis Sample (RLS)"",""ReportName"":""IT Spend Analysis Sample (RLS)"",""CapacityId"":""2C378C41-B989-4998-9FF8-046798A3572C"",""CapacityName"":""Premium Per User - Reserved"",""WorkspaceId"":""814483ee-dc75-47be-a379-db0efe658fb6"",""ObjectId"":""IT Spend Analysis Sample (RLS)"",""DatasetId"":""4506dbe0-5ecf-47f9-85a9-73ff278bca3f"",""ReportId"":""18d7271e-fb14-425c-a17b-a2ce4866dd48"",""IsSuccess"":true,""ReportType"":""PowerBIReport"",""RequestId"":""4073f095-fbb0-94bc-b05d-b..."

Test.csv

CreationDate,UserIds,Operations,AuditData
2021-09-20T20:54:27.0000000Z,brian.lofton@bisonok.com,ViewReport,"""Id"":""3880a610-6c94-44aa-998c-f6c6b8ccbebc"",""RecordType"":20,""CreationTime"":""2021-09-20T20:54:27"",""Operation"":""ViewReport"",""OrganizationId"":""00293fd9-3450-49e6-a034-ce3920c8473f"",""UserType"":0,""UserKey"":""1003200110B822A2"",""Workload"":""PowerBI"",""UserId"":""brian.lofton@bisonok.com"",""ClientIP"":""97.114.98.165"",""UserAgent"":""Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/93.0.4577.82 Safari\/537.36"",""Activity"":""ViewReport"",""ItemName"":""IT Spend Analysis Sample (RLS)"",""WorkSpaceName"":""DEMO 1 - ** TEST TEST **"",""DatasetName"":""IT Spend Analysis Sample (RLS)"",""ReportName"":""IT Spend Analysis Sample (RLS)"",""CapacityId"":""2C378C41-B989-4998-9FF8-046798A3572C"",""CapacityName"":""Premium Per User - Reserved"",""WorkspaceId"":""814483ee-dc75-47be-a379-db0efe658fb6"",""ObjectId"":""IT Spend Analysis Sample (RLS)"",""DatasetId"":""4506dbe0-5ecf-47f9-85a9-73ff278bca3f"",""ReportId"":""18d7271e-fb14-425c-a17b-a2ce4866dd48"",""IsSuccess"":true,""ReportType"":""PowerBIReport"",""RequestId"":""4073f095-fbb0-94bc-b05d-bffba3ec3566"",""ActivityId"":""bf26238f-4dd0-86c5-620c-20ab29c1704c"",""DistributionMethod"":""Workspace"",""ConsumptionMethod"":""Power BI Web"""
2021-09-20T16:45:13.0000000Z,brian.lofton@bisonok.com,ViewReport,"""Id"":""bb4d22b6-d9dc-43ee-a10b-6cf45ccb03db"",""RecordType"":20,""CreationTime"":""2021-09-20T16:45:13"",""Operation"":""ViewReport"",""OrganizationId"":""00293fd9-3450-49e6-a034-ce3920c8473f"",""UserType"":0,""UserKey"":""1003200110B822A2"",""Workload"":""PowerBI"",""UserId"":""brian.lofton@bisonok.com"",""ClientIP"":""97.114.98.165"",""UserAgent"":""Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/65.0.3325.181 Safari\/537.36"",""Activity"":""ViewReport"",""ItemName"":""IT Spend Analysis Sample (RLS)"",""WorkSpaceName"":""DEMO 1 - ** TEST TEST **"",""DatasetName"":""IT Spend Analysis Sample (RLS)"",""ReportName"":""IT Spend Analysis Sample (RLS)"",""CapacityId"":""2C378C41-B989-4998-9FF8-046798A3572C"",""CapacityName"":""Premium Per User - Reserved"",""WorkspaceId"":""814483ee-dc75-47be-a379-db0efe658fb6"",""ObjectId"":""IT Spend Analysis Sample (RLS)"",""DatasetId"":""4506dbe0-5ecf-47f9-85a9-73ff278bca3f"",""ReportId"":""18d7271e-fb14-425c-a17b-a2ce4866dd48"",""IsSuccess"":true,""ReportType"":""PowerBIReport"",""RequestId"":""b2a0095c-efc4-08a5-3348-7313c99c8c77"",""ActivityId"":""513cc6a6-a203-4cb4-afb7-a2fb170b1916"",""DistributionMethod"":""Workspace"""
2021-09-20T16:45:12.0000000Z,brian.lofton@bisonok.com,ViewReport,"""Id"":""b8b49c6d-4daf-43cf-8e0a-15f36f39212a"",""RecordType"":20,""CreationTime"":""2021-09-20T16:45:12"",""Operation"":""ViewReport"",""OrganizationId"":""00293fd9-3450-49e6-a034-ce3920c8473f"",""UserType"":0,""UserKey"":""1003200110B822A2"",""Workload"":""PowerBI"",""UserId"":""brian.lofton@bisonok.com"",""ClientIP"":""97.114.98.165"",""UserAgent"":""Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/65.0.3325.181 Safari\/537.36"",""Activity"":""ViewReport"",""ItemName"":""IT Spend Analysis Sample (RLS)"",""WorkSpaceName"":""DEMO 1 - ** TEST TEST **"",""DatasetName"":""IT Spend Analysis Sample (RLS)"",""ReportName"":""IT Spend Analysis Sample (RLS)"",""CapacityId"":""2C378C41-B989-4998-9FF8-046798A3572C"",""CapacityName"":""Premium Per User - Reserved"",""WorkspaceId"":""814483ee-dc75-47be-a379-db0efe658fb6"",""ObjectId"":""IT Spend Analysis Sample (RLS)"",""DatasetId"":""4506dbe0-5ecf-47f9-85a9-73ff278bca3f"",""ReportId"":""18d7271e-fb14-425c-a17b-a2ce4866dd48"",""IsSuccess"":true,""ReportType"":""PowerBIReport"",""RequestId"":""102f7153-27e6-a625-2337-c335e25706d1"",""ActivityId"":""513cc6a6-a203-4cb4-afb7-a2fb170b1916"",""DistributionMethod"":""Workspace"""


电源查询


【问题讨论】:

加载时截断还是只在预览中截断? @AlexisOlson,好的,好点。加载数据后,文本字符串就完成了。太好了! 【参考方案1】:

文本没有被截断 - 只有下部窗口中的显示被截断,如末尾的省略号所示。

您可以通过多种方式证明这一点。

LEN(original text) 删除了前导和尾随双引号;并且被单双引号替换的双双引号将具有与Text.Length([Audit Data]) 相同的长度 输入带有=Text.End([Audit Data],150) 之类的自定义列,您会在页面底部的预览中看到您缺少的内容。 将[Audit Data] 拆分为固定数字(例如1000),您会在不同的列中看到整个字符串。 将数据表加载到 Excel 工作表中,您会看到没有任何文本丢失

【讨论】:

以上是关于用 Csv.Document 截断的电源查询文本的主要内容,如果未能解决你的问题,请参考以下文章

用“文本溢出:省略号”截断文本

css css用省略号截断文本

css css用省略号截断文本

用链接截断 html 中的文本以显示更多/更少并将元素保留在里面

如何修复电源查询中的“值不是单个字符串”

用 CSS 截断长字符串:可行吗?