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

Last 12 Mo. Average $ Sales Measure to Include Months with Zero Dollars

Below is a matrix of sales for the last 13 months.  I am looking to calculate the last 12 month average. Within my measure "Avg $ Sales/ 12 Mo", it is not including the months with zero dollars in sales.  The result I am looking for should be 236, not 707. 

 

Can anyone help me update this measure?  Please and thank you 🙂 

 

Christina_C_0-1667494596246.png

 
Average Last 12 Mo. =
VAR NumOfMonths = 12
VAR LastSelectedDate = MAX ( 'Calendar'[Date] )
VAR Period =
    DATESINPERIOD ( 'Calendar'[Date], LastSelectedDate, -NumOfMonths, MONTH )
VAR Result =
    CALCULATE (
        AVERAGEX (
            VALUES ( 'Calendar'[Month Number] ),
            [Total Sales]
        ),
        Period
    )
VAR LastDateWithSale = MAX ( 'VALUE ENTRY'[Posting Date] )
VAR FirstVisibleDate = MIN ('Calendar'[Date])
RETURN
    IF( FirstVisibleDate <= LastDateWithSale, Result )

 

 

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , if you want inculde month with no sales

 

Rolling 12 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],MAX('Date'[Date]),-12,MONTH))/12

 

 

Do not inculde month with 0 sales

 

Rolling 12 = calculate(AverageX(Values('Date'[MONTH Year]),CALCULATE(sum(Sales[Sales Amount]))),DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-12,MONTH))

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

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

@amitchandak It worked!! Thank you so much!!

amitchandak
Super User
Super User

@Anonymous , if you want inculde month with no sales

 

Rolling 12 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],MAX('Date'[Date]),-12,MONTH))/12

 

 

Do not inculde month with 0 sales

 

Rolling 12 = calculate(AverageX(Values('Date'[MONTH Year]),CALCULATE(sum(Sales[Sales Amount]))),DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-12,MONTH))

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
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.