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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
A_a_a
Helper III
Helper III

Average of Top 5 Measures in row (matrix table)

Hi All,

I have a Matrix Table with Places, Weeks and percentage values (measure).

 

I need to calculate an average of top 5 measures in one row. So for example place 1: weeks 1 to 5, but place 3: weeks 1,2,3,4,6.

 

Is there any way to to that? I was trying different options but no results.

 

Just to highlight that percentage values are measures, which I calculated earlier.

 

A_a_a_1-1666734886886.png

 

Thanks,

G.

 

1 ACCEPTED SOLUTION

Hi, @A_a_a 

Try calculated table like:

Top5 = 
GENERATE (
    VALUES ( 'ActualData'[Place] ),
    TOPN (
        5,
        FILTER (
            SELECTCOLUMNS (
                ALL ( 'ActualData'[Place], 'ActualData'[Week] ),
                "v_Place", 'ActualData'[Place],
                "v_week", 'ActualData'[Week],
                "v_percentage", [%]
            ),
            [v_Place] = [Place]
        ),
        [v_percentage], DESC
    )
)

measure:

Average = CALCULATE(AVERAGE(Top5[v_percentage]),ALLEXCEPT(Top5,Top5[v_Place]))

veasonfmsft_0-1666839396323.png

 

Best Regards,
Community Support Team _ Eason

View solution in original post

6 REPLIES 6
v-easonf-msft
Community Support
Community Support

Hi, @A_a_a 

You may need to create a summary table to get the records of Top5 measure value in each Place.

Then you can calculate the average based on this summary table.

 

Best Regards,
Community Support Team _ Eason

Thank you.

 

I am wondering if I can create a summary table based on two columns and one measure?

 

New Table = SUMMARIZE(ActualData,ActualData[place],ActualData[Week],VALUE(ActualData[%]))
 
[%] - it is a measure. It is not working with it...
 
Any idea?
Thanks,
G.

Ok, it worked:

 

New Table = SUMMARIZE(ActualData,ActualData[place],ActualData[Week],"Measure",VALUE([%]))

Ok, but now I am strugling with the correct TopN, first of all I need top 5...

I started with:

 

Top by place and week =
RANKX(ALLSELECTED('New Table'[place],'New Table'[Week]),[Measure 2],,DESC,Dense)
 
and the output is not ideal...
A_a_a_1-1666781481053.png

I need such output

A_a_a_2-1666781617987.png

 

and not sure how to calculate average top 5 by place.

 

Please help.

Hi, @A_a_a 

Try calculated table like:

Top5 = 
GENERATE (
    VALUES ( 'ActualData'[Place] ),
    TOPN (
        5,
        FILTER (
            SELECTCOLUMNS (
                ALL ( 'ActualData'[Place], 'ActualData'[Week] ),
                "v_Place", 'ActualData'[Place],
                "v_week", 'ActualData'[Week],
                "v_percentage", [%]
            ),
            [v_Place] = [Place]
        ),
        [v_percentage], DESC
    )
)

measure:

Average = CALCULATE(AVERAGE(Top5[v_percentage]),ALLEXCEPT(Top5,Top5[v_Place]))

veasonfmsft_0-1666839396323.png

 

Best Regards,
Community Support Team _ Eason

Perfect, thank you !!!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.