Forum Discussion
Day to Day Calculated Column
- 8 years ago
Hey vega!
I was able to use LOOKUP and specify both 364 days ago, and hotel. I added a calculated column to my test data model using the following expression:
PriorYearHotelValue = IF( Sheet1[Hotel] = "A", LOOKUPVALUE(Sheet1[Value],Sheet1[Date],Sheet1[Date] - 364,Sheet1[Hotel], "A"), LOOKUPVALUE(Sheet1[Value],Sheet1[Date],Sheet1[Date] - 364,Sheet1[Hotel], "B") )In my test data, I started with three columns: Date, Hotel, & Value. The LOOKUP expression looks for the value in Sheet1[Value], where date matches 364 days ago, and hotel matches A. I only have two hotels, so my IF statement executes the first LOOKUP if matches on A, and the second if not.
Click HERE to access my .pbix file if you need it.
Hope this helps!
Hey vega!
I was able to use LOOKUP and specify both 364 days ago, and hotel. I added a calculated column to my test data model using the following expression:
PriorYearHotelValue =
IF(
Sheet1[Hotel] = "A",
LOOKUPVALUE(Sheet1[Value],Sheet1[Date],Sheet1[Date] - 364,Sheet1[Hotel], "A"),
LOOKUPVALUE(Sheet1[Value],Sheet1[Date],Sheet1[Date] - 364,Sheet1[Hotel], "B")
)
In my test data, I started with three columns: Date, Hotel, & Value. The LOOKUP expression looks for the value in Sheet1[Value], where date matches 364 days ago, and hotel matches A. I only have two hotels, so my IF statement executes the first LOOKUP if matches on A, and the second if not.
Click HERE to access my .pbix file if you need it.
Hope this helps!
Thank you, I appreciate it. I was also able to come up with an alternate solution. I'll leave it here in case it helps anyone else out in the future.
=
VAR previousDate = 'Legacy Trans'[Date]-364
RETURN
CALCULATE(
SUM('Legacy Trans'[Amount]),
ALLEXCEPT('Legacy Trans','Legacy Trans'[Hotel]),
'Legacy Trans'[Dates] = previousDate
)