Leveraging the WINDOW Function
The DAX function WINDOW is a relatively recent addition to the DAX language along with similar and related functions—INDEX, OFFSET, ORDERBY, and PARTITIONBY. These functions were released as part of an effort to bring visual-level calculations to Power BI.
In this recipe, the WINDOW function is used to compute a rolling 3-month average as well as a running total.
Getting ready
To prepare for this recipe, follow these steps:
- Download
Leveraging the WINDOW Function Start.pbixfrom the following GitHub repository: https://github.com/PacktPublishing/Power-BI-Cookbook-Third-Edition. - Open
Leveraging the WINDOW Function Start.pbixin Power BI Desktop. - Edit the
AdventureWorksquery, and change theSourceline to point to your SQL server with theAdventureWorksDW2022database installed. - Click Close & Apply from the ribbon of the Home tab.
- Save your work.