Time Series Analysis in Power BI
Kevin Barlow
Data Analytics Professional
Expanding and Rolling window functions can be applied in many different ways!
There are several calculations you can apply to specific time periods:
- RANK()
- LOOKUPVALUE()
- CHISQ.INV()
- GEOMEAN()
SAMEPERIODLASTYEAR()
Returns a table that contains a column of dates shifted one year back in time from the dates in the specified dates column, in the current context.
SAMEPERIODLASTYEAR(<dates>)
PARALLELPERIOD()
Returns a table that contains a column of dates that represents a period parallel to the dates in the specified dates column, in the current context, with the dates shifted a number of intervals either forward in time or back in time.
PARALLELPERIOD(<dates>,
<number_of_intervals>,
<interval>)
We may want to see how our exact same window looked last year.
Typical steps to this kind of analysis:
In industry, these kinds of analyses are very common. They provide two very key data points:
- How is our organization performing on a particular KPI in the context of the current year?
- How are we doing in the context of the same period of time and KPI from last year? Are we improving?
Avg Cost = CALCULATE(
AVERAGE(stores[cost]),
stores[date] >=
DATEADD(TODAY(), -30, DAY))
LY Avg Cost = CALCULATE([Avg Cost],
SAMEPERIODLASTYEAR(stores[date]))
We can calculate exactly how our data has changed from last year by applying a window to historical data.
# Assuming current month is February
CY Jan Revenue = CALCULATE(
SUM(sales[revenue]),
PREVIOUSMONTH(sales[date]))
LY Jan Revenue = CALCULATE(
[CY Jan Revenue],
SAMEPERIODLASTYEAR(sales[date]))
Jan Revenue YoY = (
([CY Jan Revenue]-[LY Jan Revenue])
/ [LY Jan Revenue])
Time Series Analysis in Power BI