Forum Discussion
AdamMG
2 years agoHelper I
Measure - moving/rolling average
Hi Everyone. I am trying to create a measure (must be measure) - moving/rolling average (2 or 5 results) for DupResult column. My Table looks like rowid DupResult OrigResult 213034 8....
- 2 years ago
Hi,
Please check the below picture and the attached pbix file.
INDEX function (DAX) - DAX | Microsoft Learn
WINDOW function (DAX) - DAX | Microsoft Learn
2 rows moving avg DupResult: = VAR _previousrow = MAXX ( OFFSET ( -1, ALL ( data ), ORDERBY ( data[rowid], ASC ), , , MATCHBY ( data[rowid] ) ), data[rowid] ) VAR _t = WINDOW ( -1, REL, 0, REL, ALL ( data ), ORDERBY ( data[rowid], ASC ), , , MATCHBY ( data[rowid] ) ) RETURN IF ( _previousrow <> BLANK () && HASONEVALUE ( data[rowid] ), AVERAGEX ( _t, data[DupResult] ) )
Jihwan_Kim
2 years agoSuper User
Hi,
Please check the below picture and the attached pbix file.
INDEX function (DAX) - DAX | Microsoft Learn
WINDOW function (DAX) - DAX | Microsoft Learn
2 rows moving avg DupResult: =
VAR _previousrow =
MAXX (
OFFSET (
-1,
ALL ( data ),
ORDERBY ( data[rowid], ASC ),
,
,
MATCHBY ( data[rowid] )
),
data[rowid]
)
VAR _t =
WINDOW (
-1,
REL,
0,
REL,
ALL ( data ),
ORDERBY ( data[rowid], ASC ),
,
,
MATCHBY ( data[rowid] )
)
RETURN
IF (
_previousrow <> BLANK ()
&& HASONEVALUE ( data[rowid] ),
AVERAGEX ( _t, data[DupResult] )
)
- AdamMG2 years agoHelper I
Hi Jihwan_Kim
Thank you very very much 😉