Hello everybody!
As a newbie, I'm approaching Power Query and Power Pivot. After the initial successes, I am now stuck with a problem and hope for expert advice.
I've already added my data to the Power Pivot data model.
I know want to calculate a power pivot measure which returns the daily average of the previous 5 years, i. e. the average for each individual day in the period 2015 - 2019.
The following approach mathematically gives the correct results...
... however, the leap day 29th February is distorting my results. While 5 values are used to calculate the average for each day, there is only 1 value for February 29 in the period 2015-2019.
Does anyone of you know a code snippet how I can replace the average value for the leap day 29th February with the value of the previous day?
Many thanks in advance.
As a newbie, I'm approaching Power Query and Power Pivot. After the initial successes, I am now stuck with a problem and hope for expert advice.
I've already added my data to the Power Pivot data model.
Date | StorageLevel |
---|---|
01/01/2015 | 165.31 |
01/02/2015 | 164.98 |
01/03/2015 | 163.43 |
... | |
11/26/2020 | 221.98 |
11/27/2020 | 220.69 |
I know want to calculate a power pivot measure which returns the daily average of the previous 5 years, i. e. the average for each individual day in the period 2015 - 2019.
The following approach mathematically gives the correct results...
Power Query:
=AVERAGEX (
SUMMARIZE (
FILTER (
Table1; (
Table1[Date] >= DATE(2015;1;1)
&& Table1[Date] <= DATE(2019;12;31)
)
);
Table1[Date]
);
CALCULATE ( SUM ( Table1[StorageLevel] ) )
)
... however, the leap day 29th February is distorting my results. While 5 values are used to calculate the average for each day, there is only 1 value for February 29 in the period 2015-2019.
Does anyone of you know a code snippet how I can replace the average value for the leap day 29th February with the value of the previous day?
Many thanks in advance.