我已经设法将一个逗号分隔的文本字符串转换成一个由 100 个组成的分组表。
前 100 个称为“100”,后 100 个称为“200”,从 101 开始。
enter image description here
这是我的步骤
enter image description here
首先,我使用逗号作为分隔标记,使用 for each 选项将文本字符串分成几列。
然后我将整个内容转换为一列。
添加索引。
添加一个模数 100
添加自定义列 "100counter": = Table.AddColumn(#"Inserted Modulo", "100counter", each if [Modulus]=99 then [Indeks]+1 else null)
忘记重命名的列步骤:D
首先使用填充,因为初始 0-100 将具有“null”作为它们的模数。
使用 Fill down second,因为如果最后一条记录没有完全在 99 结束,则它可以为 null。
按“100counter”分组,所有行。
精简代码 - 我清理了按分隔符拆分步骤中的 1700 列:
let
Source = Excel.CurrentWorkbook(){[Name="Tabel2"]}[Content],
#"Split Column by Delimiter" = //Alot of spam code here which is essentially just alll the columns being split. Mark ALL, choose split columns by delimiter, choose comma and all.
#"Transposed Table" = Table.Transpose(#"Split Column by Delimiter"),
#"Added Index" = Table.AddIndexColumn(#"Transposed Table", "Indeks", 0, 1),
#"Inserted Modulo" = Table.AddColumn(#"Added Index", "Modulus", each Number.Mod([Indeks], 100), type number),
#"Added Custom" = Table.AddColumn(#"Inserted Modulo", "100counter", each if [Modulus]=99 then [Indeks]+1 else null),
#"Filled Up" = Table.FillUp(#"Added Custom",{"100counter"}),
#"Filled Down" = Table.FillDown(#"Filled Up",{"100counter"}),
#"Grouped Rows" = Table.Group(#"Filled Down", {"100counter"}, {{"Antal", each _, type table [Column1=number, Indeks=number, Modulus=number, 100counter=number]}})
在
#"分组行"