Forum Discussion

Kuri_191's avatar
Kuri_191
Frequent Visitor
3 years ago
Solved

Summarize Table with two categories

Hello community!

 

Imagine that you have a table with a list of products and each product is given a specific rating (A,B, and C). These products are sold every year (2020 to 2022) and I want to see what is the weight of each product per year.

 

RatingYearWeight
AFY200.318069
BFY200.415842
CFY200.261139
AFY210.452256
BFY210.351522
CFY210.182581
AFY220.671916
BFY220.228346
CFY220.099738

 

As you can see, if you sum all the values for a specific year, they all add up to 1 (100%).

 

When I try to recreate this table on PowerBI, I'm struggling with the values, because it's not considering the value per year, but the value for all the years. Please see the screenshot below.

 

This is the formula that I'm currently using, with no success so far:

 

Test_Table = SUMMARIZE('Actual Input',
'Actual Input'[Rating],
'Date'[Year],
"Weight",
Divide(Calculate(COUNT('Actual Input'[concat1_ (period/rate)])),
CALCULATE(COUNT('Actual Input'[concat1_ (period/rate)]),ALL('Actual Input'),ALL('Date'[Year]))))
  • Hey Kuri_191 ,

    Taking your data sample below + DAX to create a table:

     

    Table_3_v2 = 
    ADDCOLUMNS (
        SUMMARIZE ( Table_3, Table_3[Rating], 'Date'[Year] ),
        "Weight",
            DIVIDE (
                CALCULATE ( COUNT ( Table_3[concat1_ (period/rate)] ) ),
                CALCULATE ( COUNT ( Table_3[concat1_ (period/rate)] ), ALL ( Table_3[Rating] ) )
            )
    )

     

     

4 Replies

  • ERD's avatar
    ERD
    Icon for Community Champion rankCommunity Champion

    Hey Kuri_191 ,

    Taking your data sample below + DAX to create a table:

     

    Table_3_v2 = 
    ADDCOLUMNS (
        SUMMARIZE ( Table_3, Table_3[Rating], 'Date'[Year] ),
        "Weight",
            DIVIDE (
                CALCULATE ( COUNT ( Table_3[concat1_ (period/rate)] ) ),
                CALCULATE ( COUNT ( Table_3[concat1_ (period/rate)] ), ALL ( Table_3[Rating] ) )
            )
    )

     

     

    • Kuri_191's avatar
      Kuri_191
      Frequent Visitor

      Hello Freemanz,

       

      Thanks for the reply.

       

      Here a small portion of the dataset. From all the 4 fields, only the Year is not from the same table. Year is on a dates table, but is connected with the table from the remaining 3 fields.

       

      concat1_ (period/rate)RatingYearID
      01/01/2020AA20206171
      01/01/2020AA20206188
      01/01/2020AA20206279
      01/01/2020AA20206332
      01/01/2020AA20206338
      01/01/2020AA20206398
      01/01/2020BB20206194
      01/01/2020BB20206195
      01/01/2020BB20206214
      01/01/2020BB20206222
      01/01/2020BB20206224
      01/01/2020BB20206234
      01/01/2020BB20206237
      01/01/2020BB20206242
      01/01/2020BB20206260
      01/01/2020BB20206261
      01/01/2020BB20206267
      01/01/2020BB20206273
      01/01/2020CC20206178
      01/01/2020CC20206183
      01/01/2021AA202113827
      01/01/2021AA202113847
      01/01/2021AA202113848
      01/01/2021AA202113891
      01/01/2021BB202113966
      01/01/2021BB202113989
      01/01/2021CC202113833
      01/01/2021CC202113909
      01/01/2021CC202113921
      01/01/2021CC202114042
      01/01/2021CC202114135
      01/01/2021CC202114159
      01/01/2021CC202114169
      01/01/2021CC202114195
      01/01/2021CC202114224
      01/01/2021CC202114288