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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
grifdoogindoggy
Frequent Visitor

Calculated Column Average Last Three Values

Hello, I am currently trying to find a way to average the last three values in a column. Currently, my Data Set looks like this:

RankDivisionFiscal YearParticipant Count
1A202014
2A202113
3A202212
4A2023 
5A2024 
6A2025 
7A2026 
8A2027 
9A2028 
10A2029 
11A2030 
12B2020207
13B2021196
14B2022213
15B2023 
16B2024 
17B2025 
18B2026 
19B2027 
20B2028 
21B2029 
22B2030 

 

My desired Output looks like this:

RankDivisionFiscal YearParticipant CountProjected
1A20201414
2A20211313
3A20221212
4A2023 13
5A2024 12.66667
6A2025 12.55556
7A2026 12.74074
8A2027 12.65432
9A2028 12.65021
10A2029 12.68176
11A2030 12.66209
12B2020207207
13B2021196196
14B2022213213
15B2023 205.3333
16B2024 204.7778
17B2025 207.7037
18B2026 205.9383
19B2027 206.1399
20B2028 206.594
21B2029 206.2241
22B2030 206.3193

 

If Participant Count is not blank, then it will just return that value. However, if it is blank, then it takes the average of the last 3 values before it.

 

Thank you for any help or ideas!

1 REPLY 1
sturlaws
Resident Rockstar
Resident Rockstar

Hi,

 

to solve this issue you have to create a recursive function in PowerQuery, it cannot be solved with DAX. 

A possible starting point for reading about recursion could be this blog post:
https://www.thepoweruser.com/2019/07/01/recursive-functions-in-power-bi-power-query/ 

 

You could also consider asking your question in the power query forum:
https://community.powerbi.com/t5/Power-Query/bd-p/power-bi-services 

 

Cheers,
Sturla

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.