Forum Discussion
Multiple fact tables
The issue arises because your DateTable is limited by the minimum and maximum dates in your SalesTable. Since you only have data up to September 2024, extending the DateTable to December 2024 causes the PYTD calculation to include data from the entire year 2023, which is incorrect.
Solution:
Create a Separate Date Table:
Create a new table in Power BI using the CALENDAR function to generate a complete date range from a start date to an end date. This will ensure you have all the necessary dates for your analysis, regardless of the data in your SalesTable.
Set the start date to the beginning of the year you want to analyze (e.g., 01/01/2023) and the end date to a future date (e.g., 31/12/2024).
Adjust Relationships:
Maintain the one-to-many relationship between the SalesTable and the DateTable based on the date columns in both tables.
Remove the relationship between the BudgetTable and the DateTable. This will prevent the DateTable's filter context from affecting the BudgetTable calculations.
Create a DAX Measure for YTD Sales:
Code snippet
YTD Sales =
CALCULATE(
SUM(SalesTable[Value]),
FILTER(
ALL('DateTable'),
'DateTable'[Date] <= MAX('DateTable'[Date])
)
)
please Kudos the work if it helps Accept it as Solution.