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
Mart1980
Helper I
Helper I

Average calculation

Hello ,

 

I am trying to create a measure that will basically calculate the average of a value for the last 7 days, but this has to be a calculation that every day it calculates the average of 7 days before so I cant have a set start date and end date. Can you please let me know what

that

formula would be?

5 REPLIES 5
vanessafvg
Community Champion
Community Champion

please provide an sample of what your data looks like, in text format. 





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Data-estDog
Resolver II
Resolver II

Avg7Days =
Var vDate = DATEVALUE(FORMAT(NOW(), "yyyy-MM-dd"))
Var vDateMinus7 = DATEVALUE(FORMAT(NOW() - 7, "yyyy-MM-dd"))
var vAvg = CALCULATE(
    AVERAGE(Sheet2[Value]),
    Sheet2[Create Date] >= vDateMinus7
    && Sheet2[Create Date] <= vDate
)
Return vAvg
 
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you for this. would this formula work to calculate the average of another measure ? I have just tried it and its not giving me

the option to add that other measure into the formula

Sure, but not directly. You need to apply the measure to every row of the table (sheet2 in my case) using averageX (a row level calc before aggregating)

 

Avg7DaysFromMeasure =
Var vDate = DATEVALUE(FORMAT(NOW(), "yyyy-MM-dd"))
Var vDateMinus7 = DATEVALUE(FORMAT(NOW() - 7, "yyyy-MM-dd"))
var vAvg =
CALCULATE(
    AVERAGEX(
        SUMMARIZE(
            ALLSELECTED(Sheet2),
            "TotalDays", [aaSUmDays] /*My measure*/
        ),
        [TotalDays]
    ),
    Sheet2[Create Date] >= vDateMinus7
    && Sheet2[Create Date] <= vDate
)

Return vAvg

 

that is why its best to share your data, so that the correct solution can be given.





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




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.