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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
GGDAC
Helper I
Helper I

Rolling 12 months total and Average

Dear Team I have below table with answer which I want to derive in my meansure. I want last 12 months sales total and monthly average based on my date table which is displayed in my slicer

  Month - Dec

Year - 2019    

 

 

 janfebmaraprmayjunjulaugsepoctnovdecresult
Total201015253060503595704030480
Average20101525306050359570403040
2 REPLIES 2
sanalytics
Solution Supplier
Solution Supplier

@GGDAC ,
 Please follow the below steps,

first, create a calculated table with your Month Name (like, Jan, Feb etc) and month Number. (Make sure, this calculated table should not have any relationship with your date table)
Put the calculated table's month name into a matrix visual. 
I think you have already put Year and Monthname from your date table into slicer and selected your desire month and year.
Now, create below measures,

 

Last 12 Months Sale = CALCULATE([Total Sales],DATEADD('Calendar'[Date],-12,MONTH) )
 
Total Sales  =
CALCULATE([Last 12 Months Sale],FILTER(ALL('Calendar'),CONTAINS(VALUES('Table'[Month]),'Table'[Month],'Calendar'[Month]) && MAX('Table'[Index])<=MAX('Calendar'[MonthNum]) && 'Calendar'[Year]=MAX('Calendar'[Year]) ) )

Now, Drag the total sales into matrix visual which you have created by your calculated table month name. It will show your desired result.
I think, you can achieve the average part same way.

Hope it will help you..

Regards,
snandy
 
 
 
 
 



 

amitchandak
Super User
Super User

@GGDAC 

Try like

Sales Value Last 12M =
VAR  _End = EOMONTH(Sales[Date],0)
VAR  _Star = DATE(YEAR(_EndDate),MONTH(_EndDate) - 12,1)
RETURN
CALCULATE(SUM(Sales[Value]), DATESBETWEEN(Sales [Date], _Start, __End))

Average Value Last 12M =
VAR  _End = EOMONTH(Sales[Date],0)
VAR  _Star = DATE(YEAR(_EndDate),MONTH(_EndDate) - 12,1)
RETURN
CALCULATE(Average(Sales[Value]), DATESBETWEEN(Sales [Date], _Start, __End))

 

in matrix you can use show on row to show you measure on the row. And put month on column.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.