Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
nknishant
New Member

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 

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@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))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

Ashish_Mathur
Super User
Super User

Hi,

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


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

5 REPLIES 5
nknishant
New Member

Thank you for the reply soon.👍

Ashish_Mathur
Super User
Super User

Hi,

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


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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.

nknishant
New Member

Thank you for the prompt reply. I will follow this dax method. 

amitchandak
Super User
Super User

@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))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.