Time Series Analysis in Power BI
Kevin Barlow
Data Analytics Professional
ISO 8601
FORMAT()
Example Date:
var date = January 1st 2022
# US Standard (MM DD YYYY)
var date2 = FORMAT(date, "DD MM YYYY")
# UK Standard
# 1 January 2022
var date3 = FORMAT(date, "YYYY MM DD")
# ISO Standard
# 2022 January 01
UNIX Time
Example dates and times
January 1st, 2022 06:00:00 UTC
1641016800
January 1st, 2022 18:00:00 UTC
1641060000
DATEADD()
Allows you to move a specified number of time intervals from a reference date.
DATEADD(<dates>,<number_of_intervals>,<interval>)
Examples:
DATEADD('date', 30, DAY)
var timestamp_PST =
DATEADD('timestamp_EST', -3, HOUR)
DATEDIFF()
Calculates the number of time intervals between two date objects.
DATEDIFF(<Date1>, <Date2>, <Interval>)
Examples:
DATEDIFF(DATE(2019,2,1),
DATE(2020,4,30),
MONTH)
Result: 14
Time Series does not always come in regular intervals, and depends on how the data is collected. This can be problematic:
SUMMARIZE()
your table to "smooth" out the dataset. By aggregating our dataset, we can still get valuable information on trends, even if data is missing or irregular.
Example:
SUMMARIZE('<table>',
[group_column(s)],
[new aggregated column(s)])
SUMMARIZE('sales',
sales[Quarter],
sales[Region],
"Total Sales", SUM(sales[revenue]))
Imputation - a useful strategy when we have lots of context about what the missing data value should be; this is often done when in Power Query.
Dropping data - can be used when a row or column is missing significant amounts of data; should be avoided unless strongly benefits our analysis
In the following exercises, you will be looking at the Superstore dataset. This dataset represents Point of Sale (PoS) data for Superstore locations across the United States. With it, you will be formatting dates to a correct format for further analysis.
Time Series Analysis in Power BI