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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
738o51
Helper II
Helper II

Rolling Average Calculated Column for working days only

I'm hoping I can get some help.

 

I am building a report that is intended to show recent trends in store foot traffic based on rolling averages. There are three stores:

North is open 7/7 days a week

South is open 5/7 days a week

Central is open 4/7 days a week

 

My boss wants me to define the rolling 5 day average as the following:

Sum of customers for the last 5 weekdays divided by number of weekdays that store was open. This allows us to do an apples/apples comparison between stores. See example below:

 

DayNorthSouthCentral

Sunday

200
Monday336
Tuesday647
Wednesday4110
Thursday123
Friday740
Saturday500
Sum of customers281423
Sum of weekday customers211423
Count of open weekdays554
Rolling average4.22.85.8

 

I'm having a lot of trouble getting my Dax to work on this.

 

My goal is to show a line chart where dates are the axis, legend is location, and rolling average is the value.

 

pbix here

 

Can anyone help?

1 ACCEPTED SOLUTION
dax
Community Support
Community Support

Hi @738o51 , 

I am not sure your requirement, you could refer to my sample for details. If this is not waht you want, please correct me.

Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
dax
Community Support
Community Support

Hi @738o51 , 

I am not sure your requirement, you could refer to my sample for details. If this is not waht you want, please correct me.

Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@738o51 , you can have rolling 5 days like

Rolling 5 day = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],MAX(Sales[Sales Date]),-5,Day))

@738o51 you are missing core information in your model to perform such time intelligence functionality. As a best practice, add date dimension in your model and use it for and time intelligence calculations. Once the date dimension is added, mark it as a date table on table tools.

https://perytus.com/2020/05/22/create-a-basic-date-table-in-your-data-model-for-time-intelligence-ca...

 

Once you have a date dimension in your model, you can perform all kinds of Time intelligence calculations, and here is one video on rolling average and you can tweak it is as per your need. It is always good to learn best practices and follow that rather than jumping to the solution.

 

I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.