Forum Discussion
Learner86
Helper I
5 years agoDistinct count in custom column
Hi everybody, I have a column with the name of customers, like this: Costumer A A B C C D E F F Some names appear once and other names appear multiple times. How can I write a sy...
mahoneypat
Microsoft Employee
5 years agoHere's one way to do it in the query editor. To see how it works, just create a blank query, open the Advanced Editor and replace the text there with the M code below.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclSK1YGRTmDSGYl0AZOuYNINRsYCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Customer = _t]),
#"Added Custom" = Table.AddColumn(Source, "Custom", each let thiscustomer = [Customer] in Table.RowCount(Table.SelectRows(Source, each [Customer] = thiscustomer)), Int64.Type)
in
#"Added Custom"
Pat