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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
eagerBI
Regular Visitor

Calculate Average from Top 10 Rows

Hi ,

We are working on Power BI reports for a client with below requirement:

 

Requirement:

We want to add a reference line in a bar chart below which is calculated as:

Average of TOP 10 weeks in the last 52 weeks (from today) for the selected Station and Circle (Station and Circle are slicers on the report).

  • Every week this average will get updated
  • Summarize data at Week level for All the values selected in slicers for Station and Circle and then calculate TOP 10 weeks by TPH, then take average of these 10 values.
  • Plot this average value as a reference line in the chart which shows Weekly data for TPH measure.

 

 

Logic:

Step 1: Calculate a table for last 52 weeks

 

Last 52 Weeks Table = SELECTCOLUMNS (

FILTER ('Sheet1','Sheet1'[WEEKDIFF]>=1 && 'Sheet1'[WEEKDIFF] <=52),

"ACT HOURS",Sheet1[Actual Hrs],

"TONS PROD", Sheet1[Tons Produced],

"Week Number", Sheet1[Week Number],

"Year", Sheet1[Year],

"WeekEndDate", Sheet1[WeekEndDate],

"WEEKDIFF", Sheet1[WEEKDIFF])

 

Step 2: Add RANK Column for WeekYear based on metric TPH in the table created in Step 1.

Step 3: Create table for storing TOP 10 Weeks based on RANK Column created in Step 2.

Step 4: Calculate the AVERAGE of the 10 records returned in Step 3.

 

We are stuck on Step 2. Even though the calculation is on the new table its returning records older than 52 weeks. Also its important that the Average calculation should be dynamic , so the TOP 10 records should change as per slicer selections.

 

If anyone can help on the flow of logic and DAX functions it will be great, thanks.

1 REPLY 1
v-juanli-msft
Community Support
Community Support

Hi @eagerBI

Since I don't know your data model, I can only provide a general solution, If you have further more question about implementing in your scenario, please show me some example data and expected result.

For step2, you can follow the article

Dynamic TopN & Ranking in Power BI

For step3, please note that a new table can be dynamic based on a slicer.

For step4, Reference here

AVERAGE

AVERAGEX

 

 

Best Reagrds

Maggie

Maggie

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.