Forum Discussion
3 months Moving Average
Hi All,
Can some one help me to calculate the 3 months Moving average for the below table?
| FiscalPeriodOfClose | Total Value |
| 1 | 6081867.9 |
| 2 | 5585706.8 |
| 3 | 2727995.2 |
| 4 | 7655452 |
| 5 | 2193328.2 |
| 6 | 5853917.4 |
| 7 | 2913116.1 |
| 8 | 1560797.6 |
| 9 | 186928.5 |
Hi,
Please try to create a check column first:
Check = ('Table'[FiscalPeriodOfClose]-1)/3-ROUNDDOWN('Table'[FiscalPeriodOfClose]/3,0)Then create a group column:
Group = ROUNDUP('Table'[FiscalPeriodOfClose]/3,0)Create a measure:
3Months Average = IF ( MAX ( 'Table'[Check] ) = 0, SUM ( 'Table'[Total Value] ), CALCULATE ( SUM ( 'Table'[Total Value] ), FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Group] IN DISTINCT ( 'Table'[Group] ) && 'Table'[FiscalPeriodOfClose] <= MAX ( 'Table'[FiscalPeriodOfClose] ) ) ) )/3The result shows:
Here is my test pbix:
Hope this helps.
Best Regards,
Giotto Zhi
5 Replies
- amitchandakSuper User
Try Like
CALCULATE(Average(table[Total Value]),filter(All(Table),table[FiscalPeriodOfClose]>=max(Table[FiscalPeriodOfClose])-3 && table[FiscalPeriodOfClose] <= max(table[FiscalPeriodOfClose])))The ideal would with date and date calendar
Rolling 3 = CALCULATE(Average(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],ENDOFMONTH(Sales[Sales Date]),-3,MONTH))if you need more help make me @
Appreciate your Kudos.- RanjanThammaiahHelper V
Hey,
Thanks, I have used the second formula. But the numers calculation seems to be wrong. I have added how it should be in excel with Formula below.
I need the numbers should be like this.
FiscalPeriodOfClose Total Value 3Months Average Formula Used 1 6081867.9 2,027,289 =SUM(B2)/3 2 5585706.8 3,889,192 =SUM(B2:B3)/3 3 2727995.2 4,798,523 =SUM(B2:B4)/3 4 7655452 2,551,817 =SUM(B5)/3 5 2193328.2 3,282,927 =SUM(B5:B6)/3 6 5853917.4 5,234,233 =SUM(B5:B7)/3 7 2913116.1 971,039 =SUM(B8)/3 8 1560797.6 1,491,305 =SUM(B8:B9)/3 9 186928.5 1,553,614 =SUM(B8:B10)/3 - amitchandakSuper User
- Greg_DecklerCommunity Champion
First, Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
Mainly what is your expectation of a result? Is your FiscalPeriodofClose listed as months, quarters?
- v-gizhi-msftCommunity Support
Hi,
Please try to create a check column first:
Check = ('Table'[FiscalPeriodOfClose]-1)/3-ROUNDDOWN('Table'[FiscalPeriodOfClose]/3,0)Then create a group column:
Group = ROUNDUP('Table'[FiscalPeriodOfClose]/3,0)Create a measure:
3Months Average = IF ( MAX ( 'Table'[Check] ) = 0, SUM ( 'Table'[Total Value] ), CALCULATE ( SUM ( 'Table'[Total Value] ), FILTER ( ALLSELECTED ( 'Table' ), 'Table'[Group] IN DISTINCT ( 'Table'[Group] ) && 'Table'[FiscalPeriodOfClose] <= MAX ( 'Table'[FiscalPeriodOfClose] ) ) ) )/3The result shows:
Here is my test pbix:
Hope this helps.
Best Regards,
Giotto Zhi