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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
mrbajana
Helper III
Helper III

Rolling Average considering Blank Dates

I have a model with the Fact table and the date dimension. How can I rolling average by n days considering the dates that do not have sales included within a 7-day moving average, for example?

 

2023-12-08_15h27_17.png

 

I used this formula but it only consider days with sales 

Media Movil 7 D =
VAR LastTransactionDate = MAX(Fecha[Fecha])
VAR AverageDay = 7
VAR PeriodInVisual =
FILTER(
    ALL(
        Fecha[Fecha]
    ),
    AND(
        Fecha[Fecha]> LastTransactionDate - AverageDay,
        Fecha[Fecha] <= LastTransactionDate
    )
)
VAR OutPut =
CALCULATE(
    AVERAGEX(
        Fecha,
        [Ventas]
    ),
    PeriodInVisual
)
RETURN
OutPut
2 ACCEPTED SOLUTIONS
CoreyP
Solution Sage
Solution Sage

Try replacing blanks with 0.

 

Ventas = IF( ISBLANK(SUM([value])), 0, SUM([Value]) )

View solution in original post

Ashish_Mathur
Super User
Super User

Hi,

This pattern should work

Measure = divide(calculate([Amount],datesbetween(calendar[date],min(calendar[date])-6,max(calendar[date]))),7)

Hope this helps.


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

View solution in original post

2 REPLIES 2
Ashish_Mathur
Super User
Super User

Hi,

This pattern should work

Measure = divide(calculate([Amount],datesbetween(calendar[date],min(calendar[date])-6,max(calendar[date]))),7)

Hope this helps.


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

Try replacing blanks with 0.

 

Ventas = IF( ISBLANK(SUM([value])), 0, SUM([Value]) )

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

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.