Skip to content

Average of Monthly Sales, Year to Date

>> Download the sample (Power BI)

This sample shows the average of monthly sales, year to date.

Monthly Average Sales =
AVERAGEX ( VALUES ( Calendar_Table[Month & Year] ), [Total Sales] )
Total Sales =
SUMX ( Sales_Table, Sales_Table[Quantity] * Sales_Table[Unit Price] )
YTD Monthly Average =
CALCULATE (
[Monthly Average Sales],
FILTER (
ALL ( Calendar_Table ),
Calendar_Table[Month] <= MAX ( Calendar_Table[Month] )
&& Calendar_Table[Year] = MAX ( Calendar_Table[Year] )
)
)
YTD Total Sales =
TOTALYTD ( [Total Sales], Calendar_Table[Date] )
Calendar_Table =
GENERATE (
CALENDAR ( DATE ( 2017, 1, 1 ), DATE ( 2019, 12, 31 ) ),
VAR currentDay = [Date]
VAR Day =
DAY ( currentDay )
VAR Month =
MONTH ( currentDay )
VAR Year =
YEAR ( currentDay )
RETURN
ROW ( "Day", day, "Month", month, "Year", year )
)