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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
v_mark
Helper V
Helper V

How to Exclude Blanks in Rolling Average

I was working on a rolling average for 30 days, everything works fine but I need to exclude those blanks

 

Rolling Average Changes per Day = 
VAR NumDays = 30
VAR RollingSum = CALCULATE([Ticket Total], 
DATESINPERIOD('Date'[Date], LASTDATE('Date'[Date]), -NumDays, DAY))

RETURN
DIVIDE( RollingSum, NumDays, BLANK())

 

My concern is it goes through each date on my date table(see right table) 
regardless if there is an input (see left). 
Is there a way to control that behavior and just leave those blanks as blanks as part of the moving average? 

v_mark_0-1638545867039.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @v_mark ,

Please try to update your measure [Rolling Average Changes per Day ] as below and check whether it can get your expected result.

Rolling Average Changes per Day =
VAR NumDays = 30
VAR RollingSum =
    CALCULATE (
        [Ticket Total],
        DATESINPERIOD ( 'Date'[Date], LASTDATE ( 'Date'[Date] ), - NumDaysDAY )
    )
RETURN
    IF (
        ISBLANK ( [Ticket Total] ),
        BLANK (),
        DIVIDE ( RollingSumNumDaysBLANK () )
    )

If the above one can't help you get the correct result, please provide some sample data(exclude sensitive data) and your expected result with calculation logic and special examples. Thank you.

Best Regards

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @v_mark ,

Please try to update your measure [Rolling Average Changes per Day ] as below and check whether it can get your expected result.

Rolling Average Changes per Day =
VAR NumDays = 30
VAR RollingSum =
    CALCULATE (
        [Ticket Total],
        DATESINPERIOD ( 'Date'[Date], LASTDATE ( 'Date'[Date] ), - NumDaysDAY )
    )
RETURN
    IF (
        ISBLANK ( [Ticket Total] ),
        BLANK (),
        DIVIDE ( RollingSumNumDaysBLANK () )
    )

If the above one can't help you get the correct result, please provide some sample data(exclude sensitive data) and your expected result with calculation logic and special examples. Thank you.

Best Regards

amitchandak
Super User
Super User

@v_mark , Try like

 


Rolling Average Changes per Day =
VAR NumDays = 30
VAR RollingSum = CALCULATE([Ticket Total],
DATESINPERIOD('Date'[Date], LASTDATE('Date'[Date]), -NumDays, DAY))

RETURN
if(isblank([Ticket Total]), blank(), DIVIDE( RollingSum, NumDays, BLANK()))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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