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
Anonymous
Not applicable

DAX to get moving average/sum with month without data

Hi there!

 

I did some searches over the PBI Community but I didn't anything how can I calculate moving average/sum with certain months with no data.

I need something like as below:

 

DateSum of events MoSum of events MovAvg 6 Mo
01-03-202011
01-04-2020zero events (no data)1
01-05-202023
01-06-2020zero events (no data)3
01-07-202014
01-08-2020610
01-09-2020211

 

Note: the blue line above just show you an example that I need for the next rows.

 

I am using this DAX:

 

Events 6 MO =
AVERAGEX(
DATESINPERIOD( dCalendario[Data], LASTDATE( dCalendario[Data] ), -5, MONTH ),
[Sum of Events (All)])
 
... with this chart result:
 
Capture.PNG

 

I appreciate your help with this matter.

 

 

 

2 ACCEPTED SOLUTIONS
vivran22
Community Champion
Community Champion

Hello @Anonymous 

 

Is this what you are looking for?

 

image.png

If yes, then you may use the following measure:

Runnning Sum = 
VAR _CurrentDate = MAX(ftCalendar[Date])
VAR  _StartDate = EOMONTH(_CurrentDate,-7)+1
VAR _Filter = 
    FILTER(
        All(ftCalendar[Date]),
            ftCalendar[Date] >= _StartDate
                && ftCalendar[Date] <=_CurrentDate
    )
VAR _Sum = 
    CALCULATE(SUM('Table'[Sum of events Mo]),_Filter)
RETURN
_Sum

 

If not, then please share more details in terms of expected output.

 

Cheers!
Vivek

Blog: vivran.in/my-blog
Connect on LinkedIn
Follow on Twitter

View solution in original post

v-robertq-msft
Community Support
Community Support

Hello @Anonymous 

According to the sample table you gave,I think that the [Sum of events MovAvg 6 Mo] value of the blue line should be 12,you should check if you enter the wrong value. if it's 12,you can try the following measure:

 

Events 6 MO =
CALCULATE
(SUM('Table'[Sum of events Mo])
,FILTER(ALLSELECTED('Table')
,'Table'[Date]<=MAX('Table'[Date])))

 

 

and you can get the output chart like this:

v-robertq-msft_0-1601435737810.png

 

If not,please share more details to get your expected output.

 

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

Best Regards,

Robert Qin

View solution in original post

3 REPLIES 3
v-robertq-msft
Community Support
Community Support

Hello @Anonymous 

According to the sample table you gave,I think that the [Sum of events MovAvg 6 Mo] value of the blue line should be 12,you should check if you enter the wrong value. if it's 12,you can try the following measure:

 

Events 6 MO =
CALCULATE
(SUM('Table'[Sum of events Mo])
,FILTER(ALLSELECTED('Table')
,'Table'[Date]<=MAX('Table'[Date])))

 

 

and you can get the output chart like this:

v-robertq-msft_0-1601435737810.png

 

If not,please share more details to get your expected output.

 

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

Best Regards,

Robert Qin

Ashish_Mathur
Super User
Super User

Hi,

Try this measure

=calculate([Sum of Events (All)],datesbetween(dCalendario[Data],edate(min(dCalendario[Data]),-5),max(dCalendario[Data])))

Hope this helps.


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

Hello @Anonymous 

 

Is this what you are looking for?

 

image.png

If yes, then you may use the following measure:

Runnning Sum = 
VAR _CurrentDate = MAX(ftCalendar[Date])
VAR  _StartDate = EOMONTH(_CurrentDate,-7)+1
VAR _Filter = 
    FILTER(
        All(ftCalendar[Date]),
            ftCalendar[Date] >= _StartDate
                && ftCalendar[Date] <=_CurrentDate
    )
VAR _Sum = 
    CALCULATE(SUM('Table'[Sum of events Mo]),_Filter)
RETURN
_Sum

 

If not, then please share more details in terms of expected output.

 

Cheers!
Vivek

Blog: vivran.in/my-blog
Connect on LinkedIn
Follow on Twitter

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
Top Kudoed Authors