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

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

Reply
Pan_Forex
Helper III
Helper III

Average from last 30 results and 2 filters

Hey guys,  I have a table with 4 columns: id, score, user and type. Each user can choose 4 different types(0,1,2,3). I'm trying to count the average score of the last 30 id for each player and separately 30 results for each type he chose. 

idusertypescore

 

I have already created an index column using the rankx function: index= rankx(filter(Table, [Player] = earlier([Player]) ), [id],,asc,desc)

I created a new table using generateseries: series = generateseries(Min(Table[index]), Max(Table[index]) ,1) and I connected them with the relation. 

 

My actual measure looks like that now: calculate(average(Table[game_score]), filter(all(series) , series[Value] >= max(series[Value]) -30 && series[Value] <= max(series[Value]) ))

 

The problem is when I use the filter to select a type of, for example, 1 It only shows the average of a few results found in the last 30 id.  I would like it to show the last 30 results only for type 0,1,2,3 and at the same time without selecting the filter it would show the average of the last 30 id without meaning the type

 

 

5 REPLIES 5
Pan_Forex
Helper III
Helper III

 

IDUserTypeScore
60A01
59B12
58A02
57B02
56C22
55E02
54D12
53A22
52A12
51A22
50B02
49B12
48A12
47G12
46A12
45A12
44A11
43B21
42A11
41A21
40A25
39A22
38A34
37B35
36B16
35A15
34A12
33E15
32C22
31A23
30A24
29A12
28A11
27A15
26A23
25G31
24A25
23B31
22A32
21A35
20A11
19A12
18B11
17A45
16A42
15A43
14A22
13B22
12A12
11A11
10A11
9A45
8C45
7A15
6A12
5A03
4A05
3A03
2A05
1A01

At this point, if I count the score for the last 30(largest) IDs for each player, the result is fine. However, if I filter players by "Type 0,1,2,3", the results are only counted from the last 30 IDs and I would like it to show the last 30 types by ID.

Thank you for providing the sample data.  Did you mean to say "the last 30 IDs by type"?  Your sample data doesn't have enough data points for that.

 

lbendlin_0-1670681961340.png

 

Hi, thank you for your reply! I think so, it should work then. What more do I need? I have more than 14,000 lines and over 400 users. I just pasted a small piece. I have already counted the average score for each user from the last 30 IDs. It's works.  The problem is that I do not consider the column type. When i add a fragmenter and select, for example, type 0, the filter only works in the area of just these last 30 IDs for each user. All I want when I select a filter is for it to show the last 30 types by IDs, not only inside the last 30 IDs of each user. 

Please provide sanitized sample data that fully covers your issue.
Please show the expected outcome based on the sample data you provided.

lbendlin
Super User
Super User

Please provide sanitized sample data that fully covers your issue.
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
Please show the expected outcome based on the sample data you provided.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

Helpful resources

Announcements
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.