Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
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.
Solved! Go to Solution.
@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))
Hi,
Why do you not want to use the AVERAGEX() function? Share some data to work with and show the expected result.
Thank you for the reply soon.👍
Hi,
Why do you not want to use the AVERAGEX() function? Share some data to work with and show the expected result.
Thank you @Ashish_Mathur AverageX we can also use here for the same but as per solution of row level wise.
so we using here calculate with expression and use Datesinperiod for the result.
Thank you for the prompt reply. I will follow this dax method.
@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))
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 38 | |
| 37 | |
| 33 | |
| 32 | |
| 29 |
| User | Count |
|---|---|
| 129 | |
| 88 | |
| 79 | |
| 68 | |
| 63 |