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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Pan_Forex
Helper III
Helper III

Average from last 30 results

Hello everyone, 

 

This is my first post and the beginning of my adventure with dax so please be understanding. I have a table with 3 columns: index, score and player. I try to count the average score of the last 30 indexes for each player. I have over 14,000 lines and over 300 players so for each player the last 30 indexes will be different.

ScoresScores

 

Thank you for all the great content you have here - it is a great place to learn 🙂

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Pan_Forex , Create an index column in table using DAX

 

index= rankx(filter(Table, [Player] = earlier([Player]) ), [id],,asc,desc)

 

Create a new table

series = generateseries(Min(Table[index]), Max(Table[index]) ,1)

 

then create join series[value] with rank and create a measure

 

calculate(average(Table[game_score]), filter(all(series) , series[Value] >= max(series[Value]) -30 && series[Value] <= max(series[Value]) ))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

5 REPLIES 5
DimaMD
Solution Sage
Solution Sage

Hi, @Pan_Forex Can you provide sample data with sensitive data removed

 


__________________________________________

Thank you for your like and decision

__________________________________________

Greetings from Ukraine

To help me grow PayPal: embirddima@gmail.com

Hello, yea sure 🙂 here you will find everything https://we.tl/t-X27MhOsCQD

amitchandak
Super User
Super User

@Pan_Forex , Create an index column in table using DAX

 

index= rankx(filter(Table, [Player] = earlier([Player]) ), [id],,asc,desc)

 

Create a new table

series = generateseries(Min(Table[index]), Max(Table[index]) ,1)

 

then create join series[value] with rank and create a measure

 

calculate(average(Table[game_score]), filter(all(series) , series[Value] >= max(series[Value]) -30 && series[Value] <= max(series[Value]) ))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi, thank you very much for your reply! When creating an index column, it displays an error: Unexpected value of the TIES argument in the RANKX function. The allowed values are SKIP and DENSE.

 

My function looks like this: 

index = rankx(FILTER('public players', [Player] = earlier([Player]) ), [id],,asc,desc)

I fixed the errors, corrected the relationships and everything works. Thank you very much! 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

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.