Complete the code to calculate the year-to-date sales total using DATESYTD.
Total Sales YTD = CALCULATE(SUM(Sales[Amount]), [1](Calendar[Date]))The DATESYTD function returns a set of dates from the start of the year to the current date, which is perfect for calculating year-to-date totals.
Complete the code to create a cumulative total measure that sums sales up to the current date.
Cumulative Sales = CALCULATE(SUM(Sales[Amount]), FILTER(ALL(Calendar), Calendar[Date] <= [1]))Using MAX(Calendar[Date]) gets the current date in the filter context to sum all sales up to that date.
Fix the error in this cumulative total measure by completing the blank.
Cumulative Sales = CALCULATE(SUM(Sales[Amount]), FILTER(ALL([1]), Calendar[Date] <= MAX(Calendar[Date])))The ALL(Calendar) removes filters from the Calendar table so the FILTER can compare all dates properly.
Fill both blanks to calculate the year-to-date cumulative sales correctly.
YTD Cumulative Sales = CALCULATE(SUM(Sales[Amount]), [1](Calendar[Date]), FILTER(ALL(Calendar), Calendar[Date] <= [2]))
Use DATESYTD to get year-to-date dates and MAX(Calendar[Date]) to filter dates up to the current date.
Fill all three blanks to create a cumulative total measure that resets each year.
Cumulative Sales YTD = CALCULATE(SUM(Sales[Amount]), FILTER(ALL(Calendar), Calendar[Date] <= [1] && YEAR(Calendar[Date]) = [2]), VALUES(Calendar[[3]]))
The measure sums sales up to the max date (MAX(Calendar[Date])) within the current year (YEAR(MAX(Calendar[Date]))) and filters by the Year column (Year).