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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
qwer123
Frequent Visitor

Unit store sales - How to First count daily, Second Rolling Average?

Hi Everyone,

 

I need to calculate rolling average of unit gross sales, which equal to Daily Sales/Restaurant Count.

 

I expected the rolling average = average of each daily unit gross sales, which take account of different restaurant count every day. Using the pic as an example, I expect the rolling average on 3 Nov 2021 would be equal to (2494+2604+2766)/3 = 2621. However, what it runs out is = 178110/3/23=2581. May I get your advice how to modify the code? Thanks much in advance.

Capture.PNG

 

Rolling 30 days unit gross sales =
var sum_30days = calculate([Unit gross sales], datesinperiod(table1[Deliver Date],max(table1[Deliver Date]),-30,DAY))
var days_in_30period = calculate(DISTINCTCOUNT(table1[Deliver Date]),datesinperiod(table1[Deliver Date],max(table1[Deliver Date]),-30,DAY))
return
sum_30days/days_in_30period

PBIX file for ref
https://drive.google.com/file/d/1yNUHlifEvVjarD9OawCYkMhk0YT6O6_N/view?usp=share_link

1 ACCEPTED SOLUTION

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


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

View solution in original post

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

Share the download link of the PBI file.


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

Hi,

You may download my PBI file from here.

Hope this helps.

Untitled.png


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

Thanks Ashish. May I ask one more question - if I aim to calculate rolling average by category (e.g. restaurant ID), how could I modify the code so the table can show the correct number by restaurant ID by date?

You are welcome.  Share some data and show the expected result.


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

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors