Forum Discussion

SanderBI's avatar
SanderBI
Frequent Visitor
7 years ago
Solved

Create matrix table

I'm trying to create a matrix table to work with in my report e.a. in my charts.    See below's example. On the left my current table and on the right the result I want. I've tried a few things in ...
  • v-frfei-msft's avatar
    7 years ago

    Hi SanderBI ,

     

    As Anonymous , we can pivot your table in power query. Here I create one sample for your reference. M code  as below.

     

    let
        Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtQ31DcyMLRQ0lFyBGJDpVgdFEEnIDZCF3QGYmOooBGydhN0QZB2U3RBkHYzpdhYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Dates = _t, Categories = _t, Values = _t]),
        #"Changed Type" = Table.TransformColumnTypes(Source,{{"Dates", type date}, {"Categories", type text}, {"Values", Int64.Type}}),
        #"Pivoted Column" = Table.Pivot(#"Changed Type", List.Distinct(#"Changed Type"[Categories]), "Categories", "Values", List.Sum)
    in
        #"Pivoted Column"

     

    Pbix as attached.

     

    Regards,

    Frank