Forum Discussion
Relationship between 2 tables
- 8 years ago
Hi savanahubio,
Based on my test, you should be able to use the formula below to create a new measure to calculate the forecast value, then show the created measure as Line Values on the chart to get the expected result without creating any relationships in your scenario.
Measure = CALCULATE ( SUM ( 'POS Forecast'[POS Forecast] ), FILTER ( 'POS Forecast', CONTAINS ( 'Daily Sales by Item', 'Daily Sales by Item'[Item Description], 'POS Forecast'[Item Description] ) && 'POS Forecast'[Year] = MAX ( 'Daily Sales by Item'[Year] ) && 'POS Forecast'[Week Num] = MAX ( 'Daily Sales by Item'[Week Num] ) ) )Here is the modified pbix file for your reference. :smileyhappy:
Regards
Hi savanahubio,
In addition, an alternative solution could be that firstly creating a calculate column in your Sales table to get the corresponding WeeK Starting Date for each row. The formula below is for your reference.
WeekStarting =
VAR weekNum =
WEEKNUM ( 'Sales'[Date] )
VAR year =
YEAR ( 'Date'[Date] )
RETURN
CALCULATE (
FIRSTDATE ( 'Sales'[Date] ),
FILTER (
ALL ( 'Date' ),
WEEKNUM ( 'Sales'[Date] ) = weekNum
&& YEAR ( 'Sales'[Date] ) = year
)
)
Then you should be able to create a relationship between your Sales table and Forecast table with the "WeekStarting" column. :smileyhappy:
Regards
I did the opposite of this an created the Week Ending in my Forecast table because that is what I go by. Because I have item detail in the Forecast table there are 3 values for any given week. I cannot create a relationship because there arent unique values. I think I need to create a table with just the WeekNum and the Last Day of the week and then make a relationship between both other tables.
I do not know how to go that but I will try!