Skip to main content

Provide a measure that gives the Running/cumulative total using the date table.

Table of Contents

To create a measure calculating the cumulative total of Net Sales considering the Date table being the primary date table in Power BI, follow these steps:

Measure 1: Cumulative Sales Using the FILTER Function (All Dates)

This measure calculates cumulative sales considering all dates even outside the current context. It achieves this by using the CALCULATE function along with the FILTER and ALL functions.

Measure 2: Cumulative Sales using the FILTER Function (Selected Dates)

This measure calculates cumulative sales but only for the selected dates. It uses CALCULATE with FILTER and ALLSELECTED functions. ALLSELECTED makes sure that the current context of calculation is such that only those dates currently selected get included in the calculation.

Measure 3: Cumulative Sales using Window Function (All Dates)

This measure calculates cumulative sales, considering all dates, using a window function. This uses the CALCULATE function in combination with a window function so that the cumulative total is calculated over all dates in the Date table.

Measure 4: Cumulative Sales using Window Function (Selected Dates)

It shows the cumulative sales using a window function for only the selected dates. To get this right only within the dates provided for, the CALCULATE function used with the window function, and ALLSELECTED must be in that scope or context of dates currently under selection, so that only the dates in that range will be considered in its execution. Window function would set it between the first row and the current row being considered with positions relative to one other, ordered in ascending order of dates.

This measure calculates the cumulative sales using a window function, considering only the selected dates. The CALCULATE([Net], …) calculates the Net Sales, while the Window(…) function defines the window, which spans from the absolute first position to the current relative position. This window is applied over all selected dates in the Date table, ordered in ascending order

This measure calculates the cumulative sales using a window function, considering only the selected dates. The CALCULATE([Net], …) calculates the Net Sales, while the Window(…) function defines the window, which spans from the absolute first position to the current relative position. This window is applied over all selected dates in the Date table, ordered in ascending order

Add comment