Power Query 合并查询数据格式错误 - 无法转换为数字
意图- 我有 2 个表“诊断”和“PHQ9 分数”。两个表都有两个公共列:图表编号和服务日期。在每个表中,我合并了这两列,并在两者中使用默认名称“合并”。然后我选择合并查询并使用每个表中的“合并”列作为参考列来完成合并查询。我打算将 PHQ9 表中的数据引入诊断表中。然后,power query 在每个单元格中创建一个包含单词“Table”的列。然后,我使用新列中的下拉列表从 PHQ9 表中选择我希望添加到诊断表中的数据列。
我已经查找了数据类型问题,但没有成功。
let
Source = Folder.Files("\\dc\finance team\Finance Team\PHQ9\Patrick Testing\Data\Diagnosis"),
#"Filtered Hidden Files1" = Table.SelectRows(Source, each [Attributes]?[Hidden]? <> true),
#"Invoke Custom Function1" = Table.AddColumn(#"Filtered Hidden Files1", "Transform File", each #"Transform File"([Content])),
#"Renamed Columns1" = Table.RenameColumns(#"Invoke Custom Function1", {"Name", "Source.Name"}),
#"Removed Other Columns1" = Table.SelectColumns(#"Renamed Columns1", {"Source.Name", "Transform File"}),
#"Expanded Table Column1" = Table.ExpandTableColumn(#"Removed Other Columns1", "Transform File", Table.ColumnNames(#"Transform File"(#"Sample File"))),
#"Changed Type" = Table.TransformColumnTypes(#"Expanded Table Column1",{{"Source.Name", type text}, {"Name", type text}, {"Data", type any}, {"Item", type text}, {"Kind", type text}, {"Hidden", type logical}}),
#"Expanded Data" = Table.ExpandTableColumn(#"Changed Type", "Data", {"Column1", "Column2", "Column3", "Column4", "Column5"}, {"Data.Column1", "Data.Column2", "Data.Column3", "Data.Column4", "Data.Column5"}),
#"Removed Top Rows" = Table.Skip(#"Expanded Data",1),
#"Promoted Headers" = Table.PromoteHeaders(#"Removed Top Rows", [PromoteAllScalars=true]),
#"Removed Columns" = Table.RemoveColumns(#"Promoted Headers",{"Depression 2.xlsx", "Page1_1", "Column3", "Page1_1_1", "Sheet", "false"}),
#"Split Column by Delimiter" = Table.ExpandListColumn(Table.TransformColumns(#"Removed Columns", {{"ICD-10 Codes", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "ICD-10 Codes"),
#"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"ICD-10 Codes", type text}}),
#"Filtered Rows" = Table.SelectRows(#"Changed Type1", each Text.Contains([#"ICD-10 Codes"], "F32") or Text.Contains([#"ICD-10 Codes"], "F33") or Text.Contains([#"ICD-10 Codes"], "R45")),
#"Replaced Value" = Table.ReplaceValue(#"Filtered Rows"," ","",Replacer.ReplaceText,{"ICD-10 Codes"}),
#"Extracted Date" = Table.TransformColumns(#"Replaced Value",{}),
#"Changed Type2" = Table.TransformColumnTypes(#"Extracted Date",{{"Service Date", type date}, {"Patient Chart Number", Int64.Type}}),
#"Duplicated Column" = Table.DuplicateColumn(#"Changed Type2", "Patient Chart Number", "Patient Chart Number - Copy"),
#"Duplicated Column1" = Table.DuplicateColumn(#"Duplicated Column", "Service Date", "Service Date - Copy"),
#"Merged Columns" = Table.CombineColumns(Table.TransformColumnTypes(#"Duplicated Column1", {{"Patient Chart Number - Copy", type text}, {"Service Date - Copy", type text}}, "en-US"),{"Patient Chart Number - Copy", "Service Date - Copy"},Combiner.CombineTextByDelimiter("", QuoteStyle.None),"Merged"),
#"Merged Queries" = Table.NestedJoin(#"Merged Columns", {"Merged"}, #"PHQ9 Score", {"Merged"}, "PHQ9 Score", JoinKind.LeftOuter),
#"Expanded PHQ9 Score" = Table.ExpandTableColumn(#"Merged Queries", "PHQ9 Score", {"Note Field Value"}, {"PHQ9 Score.Note Field Value"})
in
#"Expanded PHQ9 Score"
Intent -
I have 2 tables "Diagnosis" and "PHQ9 Score". Both tables have two common columns, Chart Number and Date of Service. In each table I merged these 2 columns and used the default name "Merged" in both. I then selected merge queries and used the "Merged" column in each table as the reference column to complete the merge query. I am intending to bring in data from the PHQ9 table into the Diagnosis table. power query then creates a column with the word "Table" in each cell. I then use the drop down in the new column to select the column of data from the PHQ9 table I wish to have added to the Diagnosis table.
I have looked for data type issues but no luck.
let
Source = Folder.Files("\\dc\finance team\Finance Team\PHQ9\Patrick Testing\Data\Diagnosis"),
#"Filtered Hidden Files1" = Table.SelectRows(Source, each [Attributes]?[Hidden]? <> true),
#"Invoke Custom Function1" = Table.AddColumn(#"Filtered Hidden Files1", "Transform File", each #"Transform File"([Content])),
#"Renamed Columns1" = Table.RenameColumns(#"Invoke Custom Function1", {"Name", "Source.Name"}),
#"Removed Other Columns1" = Table.SelectColumns(#"Renamed Columns1", {"Source.Name", "Transform File"}),
#"Expanded Table Column1" = Table.ExpandTableColumn(#"Removed Other Columns1", "Transform File", Table.ColumnNames(#"Transform File"(#"Sample File"))),
#"Changed Type" = Table.TransformColumnTypes(#"Expanded Table Column1",{{"Source.Name", type text}, {"Name", type text}, {"Data", type any}, {"Item", type text}, {"Kind", type text}, {"Hidden", type logical}}),
#"Expanded Data" = Table.ExpandTableColumn(#"Changed Type", "Data", {"Column1", "Column2", "Column3", "Column4", "Column5"}, {"Data.Column1", "Data.Column2", "Data.Column3", "Data.Column4", "Data.Column5"}),
#"Removed Top Rows" = Table.Skip(#"Expanded Data",1),
#"Promoted Headers" = Table.PromoteHeaders(#"Removed Top Rows", [PromoteAllScalars=true]),
#"Removed Columns" = Table.RemoveColumns(#"Promoted Headers",{"Depression 2.xlsx", "Page1_1", "Column3", "Page1_1_1", "Sheet", "false"}),
#"Split Column by Delimiter" = Table.ExpandListColumn(Table.TransformColumns(#"Removed Columns", {{"ICD-10 Codes", Splitter.SplitTextByDelimiter(",", QuoteStyle.Csv), let itemType = (type nullable text) meta [Serialized.Text = true] in type {itemType}}}), "ICD-10 Codes"),
#"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"ICD-10 Codes", type text}}),
#"Filtered Rows" = Table.SelectRows(#"Changed Type1", each Text.Contains([#"ICD-10 Codes"], "F32") or Text.Contains([#"ICD-10 Codes"], "F33") or Text.Contains([#"ICD-10 Codes"], "R45")),
#"Replaced Value" = Table.ReplaceValue(#"Filtered Rows"," ","",Replacer.ReplaceText,{"ICD-10 Codes"}),
#"Extracted Date" = Table.TransformColumns(#"Replaced Value",{}),
#"Changed Type2" = Table.TransformColumnTypes(#"Extracted Date",{{"Service Date", type date}, {"Patient Chart Number", Int64.Type}}),
#"Duplicated Column" = Table.DuplicateColumn(#"Changed Type2", "Patient Chart Number", "Patient Chart Number - Copy"),
#"Duplicated Column1" = Table.DuplicateColumn(#"Duplicated Column", "Service Date", "Service Date - Copy"),
#"Merged Columns" = Table.CombineColumns(Table.TransformColumnTypes(#"Duplicated Column1", {{"Patient Chart Number - Copy", type text}, {"Service Date - Copy", type text}}, "en-US"),{"Patient Chart Number - Copy", "Service Date - Copy"},Combiner.CombineTextByDelimiter("", QuoteStyle.None),"Merged"),
#"Merged Queries" = Table.NestedJoin(#"Merged Columns", {"Merged"}, #"PHQ9 Score", {"Merged"}, "PHQ9 Score", JoinKind.LeftOuter),
#"Expanded PHQ9 Score" = Table.ExpandTableColumn(#"Merged Queries", "PHQ9 Score", {"Note Field Value"}, {"PHQ9 Score.Note Field Value"})
in
#"Expanded PHQ9 Score"
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论