Forum Discussion
Moving average
- 3 years ago
Hi , Kleine285
I download this .pbix file , the filed in the visual is wrong, youo need to use the [Maand] filed in the 'Measures Mndst' table and [14.0] measure you created before not in the 'Table2'.
For your need , you should update the measure to this :
Moving average = var _date =SELECTEDVALUE('Mndst'[Maand]) var _this_year_month =MAXX( FILTER( 'Table 2' , [Maand] = DATE( YEAR( _date) ,MONTH(_date),1)) , [14.0]) var _last_year_dec = MAXX( FILTER( 'Table 2' , [Maand] = DATE( YEAR( _date) -1 ,12,1)) , [14.0]) return IF(_last_year_dec=BLANK(),BLANK(),DIVIDE(_last_year_dec+_this_year_month,2))The result is follows , i think that is your need :
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi Aniya Zhang,
I'm still getting an emty result for the measure.
I've added the link to the PBI.file for you to try and work your magic and a screenshot of my desired output. Please don't mind the blank cells in the sample.
ā
https://drive.google.com/file/d/17oW-dq_GRX5fzv0RP7clAv5MdvqQCgYx/view?usp=sharing
Hi , Kleine285
I download this .pbix file , the filed in the visual is wrong, youo need to use the [Maand] filed in the 'Measures Mndst' table and [14.0] measure you created before not in the 'Table2'.
For your need , you should update the measure to this :
Moving average = var _date =SELECTEDVALUE('Mndst'[Maand])
var _this_year_month =MAXX( FILTER( 'Table 2' , [Maand] = DATE( YEAR( _date) ,MONTH(_date),1)) , [14.0])
var _last_year_dec = MAXX( FILTER( 'Table 2' , [Maand] = DATE( YEAR( _date) -1 ,12,1)) , [14.0])
return
IF(_last_year_dec=BLANK(),BLANK(),DIVIDE(_last_year_dec+_this_year_month,2))
The result is follows , i think that is your need :
Best Regards,
Aniya Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
- Kleine2853 years agoNew Member
Thank you all, especially Aniya Zhang for your help.
- Kleine2853 years agoNew Member
Hi Aniya Zhang,
I would like your help regarding the measure you provided. It seems that I can't filter on institution "Instelling".
How can I make the "Moving Average" measure also work when filtering by insitution.
Thanks in advance for your help.
Isstvan