UX Engineering: Bookmarks, Selection Pane & Page Navigation
Overview & Learning Objectives
Daily sales charts are notoriously noisy: weekend spikes and weekday dips create jagged lines that obscure true business trends. To smooth out short-term fluctuations, analytics teams use **Rolling Moving Averages** (e.g. 7-day moving average, 30-day rolling revenue). In DAX, rolling windows are constructed using `DATESINPERIOD()` and `DATESBETWEEN()`.
- Master the syntax of `DATESINPERIOD(DateColumn, StartDate, NumberOfIntervals, Interval)`.
- Calculate a 7-day and 30-day rolling moving average in DAX.
- Use `DATESBETWEEN()` for custom arbitrary date ranges.
Industry Standard
Standard: Analytics dashboards at Swiggy and Amazon use 7-day and 30-day moving averages as standard overlays to track core underlying order volume growth independent of weekend spikes.
Real-World Example: Burger Point Order Velocity
Burger Point sales spike drastically on Saturdays and drop on Tuesdays. A 7-day rolling average provides a smooth trend line.
| Date | Daily Sales (₹) | 7-Day Rolling Revenue Window | 7-Day Moving Avg (₹) |
|---|---|---|---|
| 07-Oct-2026 | 14,000 | 01-Oct to 07-Oct (₹ 70,000 total) | 10,000 (70k / 7 days) |
| 08-Oct-2026 | 21,000 (Weekend spike!) | 02-Oct to 08-Oct (₹ 77,000 total) | 11,000 (77k / 7 days) |
| 09-Oct-2026 | 8,000 (Tuesday dip) | 03-Oct to 09-Oct (₹ 77,000 total) | 11,000 (Smooth trend!) |
Functions Covered in this Chapter
Here is the definition, exact syntax, parameter breakdown, and real-world business example for each function covered in this chapter:
DATESINPERIOD Function
Definition: Returns a table of dates beginning with a specified start date and continuing for the specified number and type of date intervals. Perfect for 7-day, 30-day, or 90-day rolling averages.
Trailing 30 Days Sales = CALCULATE([Total Sales], DATESINPERIOD(Dim_Date[Date], MAX(Dim_Date[Date]), -30, DAY))
Dates: Date column from a marked Date dimension.StartDate: Anchor date to begin the range from (typically `MAX(Dim_Date[Date])`).NumberOfIntervals: Number of intervals to look back or forward (-30 to look back 30 days).Interval: Interval unit: `DAY`, `MONTH`, `QUARTER`, or `YEAR`.
7D Moving Avg = DIVIDE(CALCULATE([Total Sales], DATESINPERIOD(Dim_Date[Date], MAX(Dim_Date[Date]), -7, DAY)), 7)DATESBETWEEN Function
Definition: Returns a table of dates between a specified fixed start date and end date.
Festival Period Sales = CALCULATE([Total Sales], DATESBETWEEN(Dim_Date[Date], DATE(2026, 10, 1), DATE(2026, 10, 31)))
Dates: Date column from a marked Date dimension.StartDate: Earliest date in the range (inclusive).EndDate: Latest date in the range (inclusive).
Sale Window Revenue = CALCULATE([Total Sales], DATESBETWEEN(Dim_Date[Date], DATE(2026, 10, 10), DATE(2026, 10, 25)))Common Mistakes & Limitations
- Using a positive interval (e.g. `30`) instead of `-30`, looking into the future instead of historical days.
- Dividing by a hardcoded `7` instead of dividing by `COUNTROWS(DATESINPERIOD(...))` during the first 6 days of the dataset.
Keyboard Shortcuts
| Action | Windows | Mac |
|---|---|---|
| Quick Measure: Rolling Average | Quick Measure -> Time Intelligence -> Rolling average | Quick Measure |
| Format Currency | Measure Tools -> Currency | Currency |
Pro Tips & Modern Alternatives
- Use `AVERAGEX(DATESINPERIOD(Dim_Date[Date], MAX(Dim_Date[Date]), -7, DAY), [Total Sales])` for direct moving average computation.
- Use `DATESBETWEEN` when filtering between two fixed explicit calendar dates.