Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
alfranco17
Advocate I
Advocate I

Summarize of a summarize

Hi.

I am struggling with this formula. A user can have several evaluations during a year. So I need to calculate the monthly average, and then average those monthly averages.


I am trying to summarize another summarize, but I can't get to the "MonthlyAverage" that contains the average for each month.

Any tips on how to fix it? They will be greatly appreciated.

 

Thanks.

Armando

SUMMARIZE(
    SUMMARIZE (
        'PositionEvaluationPeriod',
        Calendar[Date],        
        Users[idUser],
        "MonthlyAverage", AVERAGE ( Evaluation[Grade] )
    ),
    Users[idUser],
    "GeneralAverage", AVERAGE(MonthlyAverage)
)

 

1 ACCEPTED SOLUTION
edhans
Super User
Super User

Try this. 

Test =
SUMMARIZE(
    SUMMARIZE(
        'PositionEvaluationPeriod',
        Calendar[Date],
        Users[idUser],
        "MonthlyAverage", AVERAGE( Evaluation[Grade] )
    ),
    Users[idUser],
    "GeneralAverage", AVERAGE( [MonthlyAverage] )
)

The syntax is correct, but do not think it will work. You will probably need this:

Test =
VAR varFirstSummary =
    SUMMARIZE(
        'PositionEvaluationPeriod',
        Calendar[Date],
        Users[idUser],
        "MonthlyAverage", AVERAGE( Evaluation[Grade] )
    )
RETURN
    SUMMARIZE(
        varFirstSummary,
        Users[idUser],
        "GeneralAverage",
            AVERAGEX(
                varFirstSummary,
                [MonthlyAverage]
            )
    )

And you may still need to wrap AverageX in a CALCULATE, and you might still get wrong results. SUMMARIZE should generally only be used to create the summary fields. Use ADDCOLUMNS() to add the values.

Test =
VAR varFirstSummary =
    ADDCOLUMNS(
        SUMMARIZE(
            'PositionEvaluationPeriod',
            Calendar[Date],
            Users[idUser]
        ),
        "MonthlyAverage",
            CALCULATE(
                AVERAGE( Evaluation[Grade] )
            )
    )
RETURN
    ADDCOLUMNS(
        SUMMARIZE(
            varFirstSummary,
            Users[idUser]
        ),
        "GeneralAverage",
            CALCULATE(
                AVERAGEX(
                    varFirstSummary,
                    [MonthlyAverage]
                )
            )
    )

See Best Practices Using SUMMARIZE and ADDCOLUMNS - SQLBI for more info on this. SUMMARIZE() is a bit buggy in some cases is the reason for this.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

3 REPLIES 3
edhans
Super User
Super User

Glad to help @alfranco17 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
alfranco17
Advocate I
Advocate I

Thank you!

edhans
Super User
Super User

Try this. 

Test =
SUMMARIZE(
    SUMMARIZE(
        'PositionEvaluationPeriod',
        Calendar[Date],
        Users[idUser],
        "MonthlyAverage", AVERAGE( Evaluation[Grade] )
    ),
    Users[idUser],
    "GeneralAverage", AVERAGE( [MonthlyAverage] )
)

The syntax is correct, but do not think it will work. You will probably need this:

Test =
VAR varFirstSummary =
    SUMMARIZE(
        'PositionEvaluationPeriod',
        Calendar[Date],
        Users[idUser],
        "MonthlyAverage", AVERAGE( Evaluation[Grade] )
    )
RETURN
    SUMMARIZE(
        varFirstSummary,
        Users[idUser],
        "GeneralAverage",
            AVERAGEX(
                varFirstSummary,
                [MonthlyAverage]
            )
    )

And you may still need to wrap AverageX in a CALCULATE, and you might still get wrong results. SUMMARIZE should generally only be used to create the summary fields. Use ADDCOLUMNS() to add the values.

Test =
VAR varFirstSummary =
    ADDCOLUMNS(
        SUMMARIZE(
            'PositionEvaluationPeriod',
            Calendar[Date],
            Users[idUser]
        ),
        "MonthlyAverage",
            CALCULATE(
                AVERAGE( Evaluation[Grade] )
            )
    )
RETURN
    ADDCOLUMNS(
        SUMMARIZE(
            varFirstSummary,
            Users[idUser]
        ),
        "GeneralAverage",
            CALCULATE(
                AVERAGEX(
                    varFirstSummary,
                    [MonthlyAverage]
                )
            )
    )

See Best Practices Using SUMMARIZE and ADDCOLUMNS - SQLBI for more info on this. SUMMARIZE() is a bit buggy in some cases is the reason for this.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.