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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.