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 , Kleine285
Here are the steps you can refer to :
(1)This is my test data :
(2)We need to click "New Table" to create a table because you have a measure [14.0]:
Table 2 = ADDCOLUMNS( SUMMARIZE( ALLSELECTED('Table') , 'Table'[Mannd]) , "14.0" , [14.0])
(3)Then we need to create a measure :
Moving average = var _date =SELECTEDVALUE('Table'[Mannd])
var _last_year_month =MAXX( FILTER( 'Table 2' , [Mannd] = DATE( YEAR( _date) -1 ,MONTH(_date),1)) , [14.0])
var _last_year_dec = MAXX( FILTER( 'Table 2' , [Mannd] = DATE( YEAR( _date) -1 ,12,1)) , [14.0])
return
DIVIDE( _last_year_month + _last_year_dec , 2)
(4)We can put the filed we need and the measure on the visual and we will meet your need :
If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem.(You can upload your file to OneDrive , then you can share the OneDrive link to share your file)
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
- v-yueyunzh-msft3 years agoCommunity Support
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