将列表格式化为PowerBI/Excel中的表格。

huangapple go评论86阅读模式
英文:

Formatting a list into a table in PowerBI/Excel

问题

I have a list in my Excel file as follows:

将列表格式化为PowerBI/Excel中的表格。

如您所见,我只有一个列中的值,其他列为空白,我想要以下结果作为表格:

将列表格式化为PowerBI/Excel中的表格。

我有超过99行,有人可以帮助我使用DAX或M代码吗?
谢谢!

英文:

I have a list in my Excel file as folowing :

将列表格式化为PowerBI/Excel中的表格。

As you can see i only have the values in one column the others are blanks, i want the folowing result as a table :

将列表格式化为PowerBI/Excel中的表格。

i have more than 99 row, can someone help with dax or M code
Thank you !

答案1

得分: 6

以下是翻译好的代码部分:

let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    row_groupings = 3,
    #"Filtered Rows" = Table.SelectRows(Source, each ([Name] <> null and [Name] <> "")), 
    #"Added Index" = Table.AddIndexColumn(#"Filtered Rows", "Index", 0, 1, Int64.Type),
    #"Added Index1" = Table.AddIndexColumn(#"Added Index", "Index.1", 0, 1, Int64.Type),
    Column = Table.TransformColumns(#"Added Index1",{{"Index", each Number.Mod(_, row_groupings), Int64.Type}}),
    Row = Table.TransformColumns(Column,{{"Index.1",each Number.IntegerDivide(_, row_groupings), Int64.Type}}),
    #"Pivoted Column" = Table.Pivot(Table.TransformColumnTypes(Row, {{"Index", type text}}, "en-US"), List.Distinct(Table.TransformColumnTypes(Row, {{"Index", type text}}, "en-US")[Index]), "Index", "Name"),
    #"Removed Columns" = Table.RemoveColumns(#"Pivoted Column",{"Index.1"})
in  #"Removed Columns"

请注意,这是翻译后的代码部分,不包括问题的其他内容。

英文:

If it is always three rows, blank, three rows, you can do this in powerquery, pasted into home...advanced editor...

let Source = Excel.CurrentWorkbook(){[Name=&quot;Table1&quot;]}[Content],
row_groupings = 3,
#&quot;Filtered Rows&quot; = Table.SelectRows(Source, each ([Name] &lt;&gt; null and [Name] &lt;&gt; &quot;&quot;)), 
#&quot;Added Index&quot; = Table.AddIndexColumn(#&quot;Filtered Rows&quot;, &quot;Index&quot;, 0, 1, Int64.Type),
#&quot;Added Index1&quot; = Table.AddIndexColumn(#&quot;Added Index&quot;, &quot;Index.1&quot;, 0, 1, Int64.Type),
Column = Table.TransformColumns(#&quot;Added Index1&quot;,{{&quot;Index&quot;, each Number.Mod(_, row_groupings), Int64.Type}}),
Row = Table.TransformColumns(Column,{{&quot;Index.1&quot;,each Number.IntegerDivide(_, row_groupings), Int64.Type}}),
#&quot;Pivoted Column&quot; = Table.Pivot(Table.TransformColumnTypes(Row, {{&quot;Index&quot;, type text}}, &quot;en-US&quot;), List.Distinct(Table.TransformColumnTypes(Row, {{&quot;Index&quot;, type text}}, &quot;en-US&quot;)[Index]), &quot;Index&quot;, &quot;Name&quot;),
#&quot;Removed Columns&quot; = Table.RemoveColumns(#&quot;Pivoted Column&quot;,{&quot;Index.1&quot;})
in  #&quot;Removed Columns&quot;

将列表格式化为PowerBI/Excel中的表格。

huangapple
  • 本文由 发表于 2023年5月24日 20:17:52
  • 转载请务必保留本文链接:https://go.coder-hub.com/76323447.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定