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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Howie_fishman
Frequent Visitor

rolling 3 day total issue (when original date has blank value)

Hello. I am using the following DAX code to succesfully create a measure giving 3 day sum of "mortality count" on the date and 2 following dates when mort count is not blank.
The problem is, it will not return a value if the starting date is blank for "mortality count". 
 
13c8fd21-6343-4f72-bbba-ea432843834b.jpg

 how can i tweak this so that it will always return the next 3 non blank "mortality count" values based on the date.
 
How can I ensure that 
 
3 day rolling post morts =
VAR Date1 =
    max ( 'Calendar'[Date] )
VAR Date2 =
    MINX (
        FILTER (
            ALL ( 'Calendar'[Date] ),
            'Calendar'[Date] > Date1
                && NOT ( ISBLANK ( [Mortality Count] ) )
        ),
        'Calendar'[Date]
    )
VAR Date3 =
    MINX (
        FILTER (
            ALL ( 'Calendar'[Date] ),
            'Calendar'[Date] > Date2
                && NOT ( ISBLANK ( [Mortality Count] ) )
        ),
        'Calendar'[Date]
    )
VAR Sum1 =
    CALCULATE ( [Mortality Count], 'Calendar'[Date] = Date1 )
VAR Sum2 =
    CALCULATE ( [Mortality Count], 'Calendar'[Date] = Date2 )
VAR Sum3 =
    CALCULATE ( [Mortality Count], 'Calendar'[Date] = Date3 )
RETURN
    IF (
        ISBLANK ( [Mortality Count] ),
        BLANK (),
        Sum1 + Sum2 + Sum3
    )
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Howie_fishman ,

Thanks for Greg_Deckler's reply!
And @Howie_fishman , I have no idea what your data looks like, and the screenshot you provided is blurry, so I created sample data myself for testing:

vjunyantmsft_0-1737688779702.png

vjunyantmsft_1-1737688788838.png

vjunyantmsft_2-1737688842488.png


Then use this DAX to create a measure:

3 day rolling post morts = 
VAR Date1 =
    MAX ( 'Calendar'[Date] )
VAR NextNonBlankDates =
    TOPN (
        3,
        FILTER (
            ALL ( 'Calendar'[Date] ),
            'Calendar'[Date] >= Date1
                && NOT ( ISBLANK ( [Mortality Count] ) )
        ),
        'Calendar'[Date], ASC
    )
VAR SumMortality =
    SUMX (
        NextNonBlankDates,
        [Mortality Count]
    )
RETURN
    SumMortality

And the final output is as below:

vjunyantmsft_3-1737689508576.png


Best Regards,
Dino Tao
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

2 REPLIES 2
Anonymous
Not applicable

Hi @Howie_fishman ,

Thanks for Greg_Deckler's reply!
And @Howie_fishman , I have no idea what your data looks like, and the screenshot you provided is blurry, so I created sample data myself for testing:

vjunyantmsft_0-1737688779702.png

vjunyantmsft_1-1737688788838.png

vjunyantmsft_2-1737688842488.png


Then use this DAX to create a measure:

3 day rolling post morts = 
VAR Date1 =
    MAX ( 'Calendar'[Date] )
VAR NextNonBlankDates =
    TOPN (
        3,
        FILTER (
            ALL ( 'Calendar'[Date] ),
            'Calendar'[Date] >= Date1
                && NOT ( ISBLANK ( [Mortality Count] ) )
        ),
        'Calendar'[Date], ASC
    )
VAR SumMortality =
    SUMX (
        NextNonBlankDates,
        [Mortality Count]
    )
RETURN
    SumMortality

And the final output is as below:

vjunyantmsft_3-1737689508576.png


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

Greg_Deckler
Community Champion
Community Champion

@Howie_fishman First, try modifying your Value filter behavior to be Independent. Work with value filter behavior in Power BI - Power BI | Microsoft Learn



Follow on LinkedIn
@ 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!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors