Skip to content

Allocation of Monthly Product Budget, calculated dynamically, across different Date & Time periods

>> Download the sample (Power BI)

This sample shows how a monthly product budget can be allocated dynamically across different time periods (e.g. even down to days in a particular month, if the budget has been pre-determined at product and monthly level).

Measures - Product, Budget, & Calendar Time

Section titled “Measures - Product, Budget, & Calendar Time”
Product Budget =
CALCULATE (
SUMX (
SUMMARIZE (
Calendar_Table,
Calendar_Table[Date],
"Budgets", [Product Budget Allocation]
),
[Budgets]
),
ALLSELECTED ( Calendar_Table )
)
Product Budget Allocation =
VAR DaysinContext =
COUNTROWS ( Calendar_Table ) //Finds how many dates in date context
VAR DaysinMonth =
CALCULATE (
COUNTROWS ( Calendar_Table ),
ALL ( Calendar_Table ),
VALUES ( Calendar_Table[Month & Year] )
) //Finds how many dates within each month
VAR CurrentMonth =
SELECTEDVALUE ( Calendar_Table[Month Name] )
VAR MonthlyBudgetAmount =
CALCULATE (
SUM ( 'Product Budget'[2019 Budget] ),
FILTER (
ALL ( 'Product Budget'[Month] ),
CurrentMonth = 'Product Budget'[Month]
)
) //Sums up the Total Budget for the Current Month
RETURN
IF (
OR (
HASONEVALUE ( Calendar_Table[Date] ),
HASONEVALUE ( Calendar_Table[Month & Year] )
),
DIVIDE ( DaysinContext, DaysinMonth, 0 ) * MonthlyBudgetAmount,
MonthlyBudgetAmount
)
//Retrieves Product Budget Allocations over any date context)
Total Sales =
SUMX ( Sales_Table, Sales_Table[Unit Price] * Sales_Table[Quantity] )
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 )
)
Product Budget =
ADDCOLUMNS (
CROSSJOIN (
SUMMARIZECOLUMNS ( Sales_Table[Product] ),
DISTINCT ( Calendar_Table[Date].[Month] )
),
"2019 Budget",
CALCULATE ( [Total Sales], Calendar_Table[Year] = 2018 ) * 1.075
)