Forum Discussion

matteocarnelos's avatar
matteocarnelos
Advocate III
8 years ago
Solved

Totals in Matrix Table

Hi guys,

 

this may be a stupid question but I can't find the answer.

 

Can I modify the formula of the Total in a matrix table?

 

I try to explain better with an example.

 

These are my data:

 

 

 

 

 

 

 

 

 

 

And I wuold like to achive this result:

 

 

 

 

 

 

 

 

 

 

 

 

 

 

In Power BI, to create the column Value of the matrix (second image), I use the measure Average (Data[Value]).

 

In this way, the Subtotals are right (average of the relative Value), but this make that also the Total be an average, instead I would like that the Total to be the SUM of the AVERAGE.

 

Have you some ideas to solve this problem?

 

Thank you.

 

  • I think you need to specify the sum yourself, e.g.:

    AvgThenSum =
    VAR Avg_Basic =
        AVERAGE ( Table1[Value] )
    VAR Sum_Avg_Cat =
        SUMX (
            ADDCOLUMNS (
                SUMMARIZE ( Table1, Table1[Category] ),
                "AvgPerCat", CALCULATE ( AVERAGE ( Table1[Value] ) )
            ),
            [AvgPerCat]
        )
    RETURN
        IF ( HASONEVALUE ( Table1[Year] ), Avg_Basic, Sum_Avg_Cat )

4 Replies

  • Stachu's avatar
    Stachu
    Community Champion

    I think you need to specify the sum yourself, e.g.:

    AvgThenSum =
    VAR Avg_Basic =
        AVERAGE ( Table1[Value] )
    VAR Sum_Avg_Cat =
        SUMX (
            ADDCOLUMNS (
                SUMMARIZE ( Table1, Table1[Category] ),
                "AvgPerCat", CALCULATE ( AVERAGE ( Table1[Value] ) )
            ),
            [AvgPerCat]
        )
    RETURN
        IF ( HASONEVALUE ( Table1[Year] ), Avg_Basic, Sum_Avg_Cat )
    • matteocarnelos's avatar
      matteocarnelos
      Advocate III

      Hi Stachu, and thank you for your answer.

       

      Unfortunately I'm using Power BI only from few month, and I don't know already well the functionalities.

       

      Can you explain me, in datail, the code you have posted?

       

      Sorry me for this request.

       

      Thank you.