I am looking for the DAX measure that will calculate the following:
The average 5 daily prices of a given product if:
(a) transaction date is Day 0, e.g. if transaction date is 12/23/2019, day 1 is 12/24/2019, day 2 is 12/25/2019, day 3 is 12/26/2019, day 4 is 12/27/2019 and day 5 is 12/28/2019 - and if any of these dates is not in the pricing table, to use the next available date
(b) transaction date is Day 3 - using the transaction date in (a), day 1 is 12/21/2019, day 2 is 12/22/2019, day 4 is 12/24/2019 and day 5 is 12/25/2019 - and if the transaction date is not in the pricing table, to use the 3 consecutive dates before the transaction date and 2 consecutive days after the transaction date. Also, if any of the other dates is not in the pricing table, to use the next available date.
© transaction date is Day 6, e.g. using the transaction date in (a), day 1 is 12/18/2019, day 2 is 12/19/2019, day 3 is 12/20/2019, day 4 is 12/21/2019 and day 5 is 12/22/2019, and if any o these dates is not in the pricing table, to use the next available date.
Thank you!