我正在使用这个很棒的教程。
let
//Get data from Customers table
Source = Excel.CurrentWorkbook(){[Name="Customers"]}[Content],
//Get a list of all the values in the Age column
Ages = Table.Column(Source,"Age"),
//Find the maximum age
MaxAge = List.Max(Ages),
//The number of buckets is the max age divided by ten, then rounded up to the nearest integer
NumberOfBuckets = Number.RoundUp(MaxAge/10),
//Hash function to determine which bucket each customer goes into
BucketHashFunction = (age) => Number.RoundDown(age/10),
//Use Table.Partition() to split the table into multiple buckets
CreateBuckets = Table.Partition(Source, "Age", NumberOfBuckets, BucketHashFunction),
//Turn the resulting list into a table
#"Table from List" = Table.FromList(CreateBuckets, Splitter.SplitByNothing()
, null, null, ExtraValues.Error),
//Add a zero-based index column
#"Added Index" = Table.AddIndexColumn(#"Table from List", "Index", 0, 1),
//Calculate the name of each bucket
#"Added Custom" = Table.AddColumn(#"Added Index", "Bucket",
each Number.ToText([Index]*10) & " to " & Number.ToText(([Index]+1)*10)),
//Find the number of rows in each bucket - ie the count of customers
#"Added Custom1" = Table.AddColumn(#"Added Custom", "Count", each Table.RowCount([Column1])),
//Remove unnecessary columns
#"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"Column1", "Index"})
in
#"Removed Columns"
最终结果是:
我想知道如何将所有年龄超过 50 岁的人都放入一个名为“50+”的桶中?