Forum Discussion
Calculate MTD Values from two disconnected Tables.
- Anonymous1 year ago
Hi DeepakSharma_01 ,
In the solution I originally provided, there was no relationship between the date table and the budget table.
To reproduce your problem I created a relationship between the two tables.
The relationship between two tables can be ignored by using the REMOVEFILTERS function.
The modified syntax is as follows:
M_BUDGET_MTD_SALES_Test = VAR CurrentDate = MAX(DIM_DATE[DATE]) VAR Month_start = DATE(YEAR(CurrentDate), MONTH(CurrentDate), 1) VAR Month_end = EOMONTH(CurrentDate, 0) VAR TotalMonthBudget = CALCULATE( SUM(BUDGET_FORECAST[BUDGET]), REMOVEFILTERS(DIM_DATE), BUDGET_FORECAST[MONTH] = EOMONTH(CurrentDate, 0) ) RETURN IF( CurrentDate >= Month_start && CurrentDate <= Month_end, TotalMonthBudget, BLANK() )The final page visualization is shown below:
If it hasn't been resolved, please provide a Power BI Desktop file in progress (with sensitive information removed) that fully covers your issue or question in a usable format (not a screenshot). You can upload the PBIX file to a cloud storage service such as OneDrive, Google Drive (set up public access), SharePoint, or a Github repository, and then share the URL of the file.
The pbix file is attached.
If you have any other questions please feel free to contact me.
Best Regards,
Yang
Community Support TeamIf there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
DeepakSharma_01 Hi!
You need a measure that assigns the same total monthly budget to each day of that month. You can achieve this with the following approach:
M_BUDGET_MTD_SALES_Test =
VAR CurrentDate = MAX(DIM_DATE[DATE])
VAR MonthStart = DATE(YEAR(CurrentDate), MONTH(CurrentDate), 1)
VAR MonthEnd = EOMONTH(CurrentDate, 0)
VAR TotalMonthBudget =
CALCULATE(
SUM(BUDGET_FORECAST[BUDGET]),
BUDGET_FORECAST[MONTH] = MonthEnd
)
RETURN
TotalMonthBudget
BBF