Forum Discussion

BeenSearching's avatar
BeenSearching
Frequent Visitor
9 years ago
Solved

Multi value category + Adhoc Filter

I have a list of employees with category fields that define each employee's work type. Employees can have more than one type. Here is an example:    So far I've been able to find varias ways ...
  • v-caliao-msft's avatar
    9 years ago

    BeenSearching,

     

    You could unpivot this table, and then count the Cateogrys.

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMgABQyUdJefEktT0/KJKZLYRkK0UqwNVBeahSsLYxghVxhBV2CVNiLLIlCiLzIhSZQ53DkLMAs0V2HVa4nErpnJDA9KU4w/yWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Employee = _t, Category1 = _t, Category2 = _t, Category3 = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Employee", Int64.Type}, {"Category1", type text}, {"Category2", type text}, {"Category3", type text}}),
        #"Unpivoted Columns" = Table.UnpivotOtherColumns(#"Changed Type", {"Employee"}, "Attribute", "Value"),
        #"Removed Blank Rows" = Table.SelectRows(#"Unpivoted Columns", each not List.IsEmpty(List.RemoveMatchingItems(Record.FieldValues(_), {"", null})))
    in
        #"Removed Blank Rows"

     

     

     

    Regards,

    Charlie Liao