Forum Discussion
Moving average based on prior N rows
- 6 years ago
The comma goes before the All(). Try doing just All('Normalized Calendar') instead (remove the column reference).
Regards,
Pat
- 6 years ago
StephaneMA colum type is whole number/decimal. Can you copy the table which i shared above and create the same measure (not calculated column) without any edits. Also share the snapshot.?
| Weeknumber | Subs |
| 1 | 282 |
| 2 | 508 |
| 3 | 540 |
| 4 | 518 |
| 5 | 717 |
| 6 | 599 |
| 7 | 622 |
| 8 | 416 |
| 9 | 603 |
| 10 | 622 |
| 11 | 730 |
| 12 | 617 |
| 13 | 618 |
Moving Avg =
VAR n = 5
VAR _selectedweekno =
SELECTEDVALUE ( 'Table'[Weeknumber] )
VAR result =
CALCULATE (
AVERAGE ( 'Table'[Subs] ),
FILTER (
ALL ( 'Table'[Weeknumber] ),
'Table'[Weeknumber] <= _selectedweekno
&& 'Table'[Weeknumber] >= _selectedweekno - n
)
)
RETURN
IF(_selectedweekno>=n,result,BLANK())
Did I answer your question? Mark my post as a solution!
Appreciate with a kudos 🙂
I appreciate the help but I do not get the same result at all. I created a new table with the same data to replicate your formula but I get bery different results....
I am not sure at this point what I am doing wrong to get this result.
- nandukrishnavs6 years ago
Community Champion
StephaneMA colum type is whole number/decimal. Can you copy the table which i shared above and create the same measure (not calculated column) without any edits. Also share the snapshot.?
- StephaneMA6 years agoFrequent Visitor
That did it.......!
Thank you nandukrishnavs.
There must be something wromng with the original dataset. I will fix that issue now that I have a working average working!
I really appreciate your assistance.