cancel
Showing results for
Did you mean:

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

New Member

## Average of the lowest 40

I have been tryng to create a measure that calculates the average of the 'best' 40 results from site A by period. Lower scores are better and zero represents no score and needs to be ignored. Sample data below. There are hundreds of scores per period at site A. Can anyone help? Please 🙂

 Site Period Score A 100 1.7 A 100 1.65 A 100 1.55 A 100 1.6 B 100 0 A 100 1.59 A 101 1.45 A 101 1.55 A 101 1.75 A 101 1.55 A 101 1.9 B 101 0 B 101 1.75

1 ACCEPTED SOLUTION
Frequent Visitor

Hey Jimmy17.
You could first create a calculated column which counts the values which are lower than the value in the current row.
Something like this should work:

Rank =
VAR ScoreCurrentRow = Score[Score]
VAR SiteCurrentRow = Score[Site]
VAR PeriodCurrentRow = Score[Period]
return COUNTROWS(FILTER(Score, Score[Score] < ScoreCurrentRow && SiteCurrentRow = Score[Site] && PeriodCurrentRow = Score[Period] &&  Score[Score] <> 0 )) + 1

After this you could create a measure which calculates the average over the site and the period, but only over the top 40 (In my example it was 2):
AVG = CALCULATE(AVERAGE(Score[Score]), Score[Score] <> 0, Score[Rank] <= 2)

Frequent Visitor

Hey Jimmy17.
You could first create a calculated column which counts the values which are lower than the value in the current row.
Something like this should work:

Rank =
VAR ScoreCurrentRow = Score[Score]
VAR SiteCurrentRow = Score[Site]
VAR PeriodCurrentRow = Score[Period]
return COUNTROWS(FILTER(Score, Score[Score] < ScoreCurrentRow && SiteCurrentRow = Score[Site] && PeriodCurrentRow = Score[Period] &&  Score[Score] <> 0 )) + 1

After this you could create a measure which calculates the average over the site and the period, but only over the top 40 (In my example it was 2):
AVG = CALCULATE(AVERAGE(Score[Score]), Score[Score] <> 0, Score[Rank] <= 2)

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

#### Power BI Monthly Update - June 2024

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

#### New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors
Top Kudoed Authors