>> Download the sample (Power BI)
This sample allocates a monthly product budget down to individual days without using model relationships (with the Calendar Table), using instead one of two methods: the FILTER function or the TREATAS function.
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 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)Product Budget Allocation 2
Section titled “Product Budget Allocation 2”Product Budget Allocation 2 =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 MonthlyBudgetAmount = CALCULATE ( SUM ( 'Product Budget'[2019 Budget] ), TREATAS ( VALUES ( Calendar_Table[Month Name] ), '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)