Skip to main content

Give some examples of measures we can create using the Window Function.

Table of Contents

How to create a rolling 12 months average?

Window functions can be used to create measures for running totals, rolling totals, month-to-date, quarter-to-date, year-to-date, and averages, among many other calculations.

Example: Rolling 30 measure

Since month-year text cannot be sorted directly, a sort column is needed in the formula to create a rolling month measure.

Rolling 12 Month

Average of Rolling 12 months

For running totals or cumulative calculations, we need to start from the 0/1 absolute (fixed) position. In this approach, I am constructing the formula using the date, which allows me to calculate the cumulative totals at various levels, such as week, month, quarter, and year.

Date Wise running total

By controlling the cumulative formula with partitions, we can calculate MTD (Month-to-Date), QTD (Quarter-to-Date), and YTD (Year-to-Date).

Add comment