>> 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).
Dashboard - Snippet
Section titled “Dashboard - Snippet”
Data Model - Snippet
Section titled “Data Model - Snippet”
Measures - Product, Budget, & Calendar Time
Section titled “Measures - Product, Budget, & Calendar Time”Product Budget
Section titled “Product Budget”Product Budget =CALCULATE ( SUMX ( SUMMARIZE ( Calendar_Table, Calendar_Table[Date], "Budgets", [Product Budget Allocation] ), [Budgets] ), ALLSELECTED ( Calendar_Table ))Product Budget Allocation
Section titled “Product Budget Allocation”Product Budget Allocation =VAR DaysinContext = COUNTROWS ( Calendar_Table ) //Finds how many dates in date contextVAR DaysinMonth = CALCULATE ( COUNTROWS ( Calendar_Table ), ALL ( Calendar_Table ), VALUES ( Calendar_Table[Month & Year] ) ) //Finds how many dates within each monthVAR 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 MonthRETURN 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
Section titled “Total Sales”Total Sales =SUMX ( Sales_Table, Sales_Table[Unit Price] * Sales_Table[Quantity] )Tables
Section titled “Tables”Calendar_Table
Section titled “Calendar_Table”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
Section titled “Product Budget”Product Budget =ADDCOLUMNS ( CROSSJOIN ( SUMMARIZECOLUMNS ( Sales_Table[Product] ), DISTINCT ( Calendar_Table[Date].[Month] ) ), "2019 Budget", CALCULATE ( [Total Sales], Calendar_Table[Year] = 2018 ) * 1.075)