Microsoft Power BI Complete Reference
上QQ阅读APP看书,第一时间看更新

Prior Year Sales 

A lot of time series analysis consists of comparing current metrics to the previous month or previous year. There are many functions in DAX that work in conjunction with the CALCULATE function to make these types of calculations easy. You are going to create a new measure to return the total sales for the prior year.

Create a new calculated measure on your Internet Sales table using the following DAX formula:

Figure 18-Create a new calculated measure on your Internet sales

CALCULATE allows you to ignore or even change the current filter context. In the preceding formula, CALCULATE is used to take the current filter context and change it to one year ago. This calculated measure also works at the day, month, quarter, and year level of the hierarchy. For example, if you are looking at sales for June 15, 2018, then the Prior Year Sales measure would return sales for June 15, 2017. However, if you were simply analyzing your sales aggregated at the month level for June 2018, then the measure would return the sales for June 2017.

For a comprehensive list of all the built-in time intelligence functions, please take a look at https://tinyurl.com/pbiqs-timeintel ligence .