Excel 2016将重复行转换为列

时间:2016-02-25 08:31:23

标签: excel powerquery tabular excel-2016

我在一栏中有以下数据:

ABNANL2A
940
ABNANL2A
:20:ABN AMRO BANK NV
:25:233835613
:28:19901/1
:60F:C110717EUR1333,58
:61:1107160718D12,75N426NONREF
:86:BEA   NR:5FLM01   16.07.11/15.09 OLENBERG EXPL. BURG,PAS018
:62F:C110718EUR1320,83
-
ABNANL2A
940
ABNANL2A
:20:ABN AMRO BANK NV
:25:233835613
:28:20001/1
:60F:C110718EUR1320,83
:61:1107190719D57,87N446NONREF
:86:GEA               19.07.11/07.58 HILTON - HEATHROW HOUNSL,PAS018
GBP 50,00 1EUR=0,8640055 GBP     KOSTEN EUR2,25 ACHTERAF BEREKEND
:62F:C110719EUR1262,96
-
ABNANL2A
940
ABNANL2A
:20:ABN AMRO BANK NV
:25:233835613
:28:20101/1
:60F:C110719EUR1262,96
:61:1107200720C82,N196NONREF
:86:GIRO  45588 taxservice    TEVEELBET. NR.2
MOTORRYTUIGENB.11 *B         *
:62F:C110720EUR1287,31
-

**请注意,文本行(#86)可以在一行或多行上,并在几个字符后添加换行符。*

原始文件较长,我希望在Excel 2016中使用电源查询对其进行转换(如果可能,不使用M代码)。

我已经看到很多用于转换表格表的解决方案,但问题是某些行包含列标题和数据。基本上所有之间:每行是标题,后面的部分是“值”。

我想将此转换为以下内容:

enter code here

   20             | 25        | 28
 ABN AMRO BANK NV | 233835613 | 19901/1
 ABN AMRO BANK NV | 233835613 | 20001/1
 ABN AMRO BANK NV | 233835613 | 20101/1

剥离列并更改数据没有问题。只需将重复的行转换为列即可。 感谢帮助!

2 个答案:

答案 0 :(得分:1)

您可以通过转动列名来实现您请求的转换部分。请在下面找到如何识别和提取它们的建议。

最好在导入过程中解决换行问题:http://blog.crossjoin.co.uk/2016/02/16/working-with-csv-files-that-contain-rogue-line-breaks-in-power-query-and-power-bi/ 否则你需要更多的M-acrobat才能解决它。

@Query("DELETE FROM Person entity WHERE entity.id = :id")

答案 1 :(得分:0)

Excel 2016查询代码的荷兰语版本(刚刚翻译,与@ImkeF相同):

let
Source = Excel.CurrentWorkbook(){[Name="Tabel1"]}[Content],
 #"Changed Type1" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
#"Added Index" = Table.AddIndexColumn(#"Changed Type1", "Index", 1, 1),
 HeaderSplitPosition = Table.AddColumn(#"Added Index", "SplitHeader", each if Text.Start([Column1],1)=":" then List.Last(List.FirstN(Text.PositionOf([Column1], ":", Occurrence.All),2)) else ""),
 SeparateHeader = Table.AddColumn(HeaderSplitPosition, "Header", each try Text.Trim(Text.Range([Column1],0,[SplitHeader]), ":") otherwise ""),
 SeparateBody = Table.AddColumn(SeparateHeader, "Value", each try Text.Range([Column1],[SplitHeader]+1,Text.Length([Column1])-[SplitHeader]-1) otherwise [Column1])

in
 SeparateBody