In the previous section of this chapter, we looked at creating a quick measure for year-to-date totals. The DAX expression that is created for this measure is an example of the Cumulative Total pattern. In this case, the pattern is used to create a running total of the Sales Amount field by the Date field.
The following code is the DAX expression that was created for this example:
Sales Amount running total in Date =
CALCULATE (
SUM ( 'Sales'[Sales Amount] ),
FILTER (
ALLSELECTED ( 'Date Table'[Date] ),
ISONORAFTER ( 'Date Table'[Date], MAX ( 'Date Table'[Date] ), DESC )
)
)
- The expression works by using the FILTER and ISONORAFTER functions to return a table of dates that are less than or equal to the date of the current row.
- The measure then calculates the SUM of Sales Amount for all sales...