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
paulsmit
Frequent Visitor

Minimum and Maximum weekly average by location

Hi,

 

I'm looking to see if the gap between the highest weekly location average index and the lowest weekly location average index is growing.  

 

WeekLocationIndex
1Hartington100.00
1Borrowdale95.44
1Borrowdale83.76
1Hartington100.00
1Borrowdale96.33
1Borrowdale84.99
1Snowdon91.73
1Snowdon98.27
1Snowdon89.30
1Treyarnon97.37
1Treyarnon100.00
1Treyarnon99.16
2London100.00
2London95.44
2Cambridge83.76
2Cambridge100.00
2Scotland96.33
2Scotland84.99
2Scotland91.73
2Derby98.27
2Derby89.30
2Derby97.37
2Derby100.00
2Mansfield99.16

 

From the data above I would expect to get the following results

 

WeekMin IndexMax IndexDiff between Max and Min Index
190.13100.009.87
291.0299.168.14

 

Cheers

 

Paul

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

Ah, OK.

Min Index = MINX(
ADDCOLUMNS( SUMMARIZE( 'Table', 'Table'[Location] ), "@avg", CALCULATE( AVERAGE('Table'[Index]) ) ),
[@avg]
)

I think that should do it.

View solution in original post

5 REPLIES 5
johnt75
Super User
Super User

Ah, OK.

Min Index = MINX(
ADDCOLUMNS( SUMMARIZE( 'Table', 'Table'[Location] ), "@avg", CALCULATE( AVERAGE('Table'[Index]) ) ),
[@avg]
)

I think that should do it.

Thank you so much 🙂  

If for some reason I needed to take this to the next level and I wanted to get the min and max based on the average of the top 3 and bottom 3 scoring locations (rather than just the top and bottom scoring locations) is that possible?

TOPN is the function you'd need to look at. You can specify whether the value you are ranking on should be ascending or descending, so you can get either the top or bottom 3. The actual code for ranking would depend on whether you wanted to take absolute values or averages, but you would then be able to run AVERAGEX over the tables returned by TOPN

johnt75
Super User
Super User

Create the below 3 measures

Min Index = MIN( 'Table'[Index] )
Max Index = MAX( 'Table'[Index] )
Diff between Min and Max Index = [Max Index] - [Min Index]

Then add all 3 measures to a table, or other visual, with the Week column from your table

Apologies, I probably didn't explain in my initial post that I need to average the index for each location before I find the min and max values

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.