可以使用以下代码来更改表格的默认聚合方式(假设使用的是Power BI):
例如,以下代码将选择每个列的正确聚合方式,以确保表格可视化不会自动聚合数据:
table = Table.FromRecords(records),
types = Record.FieldTypes(records{0}),
columns =
Table.TransformColumns(table, each
let
colName = Text.From(List.PositionOf(_ [ColumnNames], [Name])),
colType = types {[Name]}
in
if colType = type number or colType = type any then
Table.TransformColumns(_, {colName, each _})
else
Table.TransformColumns(_, {colName, each Text.Combine(List.Transform(_, Text.From)), type text})),
groupByColumns = List.RemoveFirstN(Table.ColumnNames(table), List.Count(keyColumns)),
grouped = Table.Group(columns, groupByColumns, grouping as g, List.Buffer(table))
in
grouped
这些更改将确保表格可视化反映出你的数据的正确聚合方式。