Forum Discussion

nknishant's avatar
nknishant
New Member
9 months ago
Solved

Rolling Avg

I want to know how we write the Dax code in Rolling of average sales without use of averagex function in easiest way.   can you please help here. amitchandak 
  • amitchandak's avatar
    9 months ago

    nknishant , if you need row level avg 

    Rolling 12 = CALCULATE(Average(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],MAX('Date'[Date]),-12,MONTH))

     

    if not 

     

    Rolling 12 Avg = CALCULATE(Divide( sum(Sales[Sales Amount]) , distinctcount('Date'[Month Year]) ) ,DATESINPERIOD('Date'[Date],MAX('Date'[Date]),-12,MONTH))

     

    or

    Rolling 12 Avg = CALCULATE(Divide( sum(Sales[Sales Amount]) , countrows(sumamrize(Sales,'Date'[Month Year]) ) ,DATESINPERIOD('Date'[Date],MAX('Date'[Date]),-12,MONTH))

  • Ashish_Mathur's avatar
    9 months ago

    Hi,

    Why do you not want to use the AVERAGEX() function?  Share some data to work with and show the expected result.