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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
WePowerBI
New Member

Moving average in 5 day intervals

Hi
I want to figure out a moving average of sales in 5 day intervals. want to show the average of sales in the last 5 days for each day. I would then like to use this value in a line chart. Can anyone help me with a DAX formula for this? 

4 REPLIES 4
v-lid-msft
Community Support
Community Support

Hi @WePowerBI ,

 

We can use the following measure to meet your requirement:

 

Measure = 
CALCULATE (
    AVERAGE ( 'Table'[value] ),
    FILTER (
        ALLSELECTED ( 'Table' ),
        'Table'[Date] <= MAX ( 'Table'[Date] )
            && 'Table'[Date]
                > MAX ( 'Table'[Date] ) - 5
    )
)

 

Then we can get the result like this,

 

31.png

 

If it doesn’t meet your requirement, could you please show the exact expected result based on the table that we have shared?

 

BTW, pbix as attached.


Best regards,

 

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

This is what I want to accomplish in Power BI. In my Power BI dataset, I have a date table and a sales table that has a date table associated with the date table. How can I achieve the same thing in Power BI?

 

https://wesafeit-my.sharepoint.com/:x:/g/personal/peterfritzon_wesafe_se/Ef1nM8-rNqxNjtCIINElwxABabc... 

Hi @WePowerBI ,

 

How about the result after you follow the suggestions mentioned in my original post? Please try to unpivot the date column in power query editor if your date is multi columns.


Best regards,

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Greg_Deckler
Super User
Super User

Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.