Forum Discussion

Hadi14's avatar
Hadi14
Regular Visitor
1 year ago
Solved

countrow in power query whitout help table in M language

I have a table that contains national codes. I want to add a column to this table without an auxiliary table that displays the number of occurrences of each national code.
  • p45cal's avatar
    p45cal
    1 year ago

    = Table.AddColumn(Source, "Count", each List.Count(List.Select(Source[code],(x)=>x=[code])))

     

     

    To paste into Advanced Editor:

    let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSszJVNJRMlKK1YlWKkqtSgRyjMGcrPyMPLhMcWJRIoQTCwA=", BinaryEncoding.Base64), Compression.Deflate)),{"name","code"}),
    AddCustom = Table.AddColumn(Source, "Count", each List.Count(List.Select(Source[code],(x)=>x=[code])))
    in
    AddCustom