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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
DeepDive
Helper IV
Helper IV

How to caclulate Rolling 12 month and rolling 3 month average.

RollingUntitled.png

 

I have sales data (where day wise sales is there)linked to DimDate table, My requirement is to get 12 months and 3 months rolling average against respective date and also how to calculate for average for initial dates where 12 months and 3 months funda is not applicable.

I need to prepare both graph and Matrix.

For Ex (Calculation) :

Rolling Avg 12 Months of 7/1/2019 = Average of month Sales from ( 8/1/2018 to 7/1/2019)

Rolling Avg 3 Months of 7/1/2019 = Average of month Sales from ( 5/1/2019 to 7/1/2019)


Am using below formula for 3 months rolling avg -
"Rolling 3 Months =
CALCULATE([TotalSales], DATESINPERIOD('Date'[Date],LASTDATE('Date'[Date]),-3,MONTH))"

Experts Kindly help !!

1 ACCEPTED SOLUTION
v-xuding-msft
Community Support
Community Support

Hi @DeepDive ,

I created a sample you can have a try.

  • create a calendar table
Table 2 = CALENDARAUTO()

2.PNG

  • create measures
3M = 
DIVIDE(CALCULATE(  
    SUM('Table'[Sum of Month Sales]) , 
   DATESINPERIOD( 'Table 2'[Date], MAX('Table 2'[Date]), -3, MONTH ) ),CALCULATE(  
    DISTINCTCOUNT('Table'[Date]) , 
   DATESINPERIOD( 'Table 2'[Date], MAX('Table 2'[Date]), -3, MONTH ) ))

12M = IF(MAX('Table'[Sum of Month Sales]) = BLANK(),BLANK(),
DIVIDE(CALCULATE(  
    SUM('Table'[Sum of Month Sales]) , 
   DATESINPERIOD( 'Table 2'[Date], MAX('Table 2'[Date]), -12, MONTH ) ),CALCULATE(  
    DISTINCTCOUNT('Table'[Date]) , 
   DATESINPERIOD( 'Table 2'[Date], MAX('Table 2'[Date]), -12, MONTH ) )))

1.PNG

Best Regards,

Xue

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

Best Regards,
Xue Ding
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

1 REPLY 1
v-xuding-msft
Community Support
Community Support

Hi @DeepDive ,

I created a sample you can have a try.

  • create a calendar table
Table 2 = CALENDARAUTO()

2.PNG

  • create measures
3M = 
DIVIDE(CALCULATE(  
    SUM('Table'[Sum of Month Sales]) , 
   DATESINPERIOD( 'Table 2'[Date], MAX('Table 2'[Date]), -3, MONTH ) ),CALCULATE(  
    DISTINCTCOUNT('Table'[Date]) , 
   DATESINPERIOD( 'Table 2'[Date], MAX('Table 2'[Date]), -3, MONTH ) ))

12M = IF(MAX('Table'[Sum of Month Sales]) = BLANK(),BLANK(),
DIVIDE(CALCULATE(  
    SUM('Table'[Sum of Month Sales]) , 
   DATESINPERIOD( 'Table 2'[Date], MAX('Table 2'[Date]), -12, MONTH ) ),CALCULATE(  
    DISTINCTCOUNT('Table'[Date]) , 
   DATESINPERIOD( 'Table 2'[Date], MAX('Table 2'[Date]), -12, MONTH ) )))

1.PNG

Best Regards,

Xue

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

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

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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