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.pbix
from the following GitHub repository: https://github.com/PacktPublishing/Power-BI-Cookbook-Third-Edition. - Open
Leveraging the WINDOW Function Start.pbix
in Power BI Desktop. - Edit the
AdventureWorks
query, and change theSource
line to point to your SQL server with theAdventureWorksDW2022
database installed. - Click Close & Apply from the ribbon of the Home tab.
- Save your work.