Home » DAX » DAX – TOTALYTD Function

DAX – TOTALYTD Function

TOTALYTD

Evaluates the year-to-date value of the expression in the current context. It comes under Time Intelligence Dax function category.

Syntax:

TOTALYTD(<expression>,<dates>,<filter>,<year_end_date>)




Description:

S no. Parameter Description
1 expression An expression that returns a scalar value.
2 date A column that contains dates.
3 filter (optional) An expression that specifies a filter to apply to the current context.
4 year_end_date (optional) A literal string with a date that defines the year-end date.

The default is December 31.

So, Let’s start with an example, download the sample Dataset from below link





Step-1: Create a calendar table to using existing dataset “Order Date” column.

Go to Modeling Tab > Click to table icon & write below DAX

Calendar = 
CALENDAR(MIN('Global-Superstore'[Order Date]), 
MAX('Global-Superstore'[Order Date]))

Step-2: After that create a relationship between both table.

Relationship




Step-3: Now, create a measure to calculate the running total sum for sales.

YTDSales =
TOTALYTD(SUM('Global-Superstore'[Sales]), 'Calendar'[Date])

Step-4: Drag YTDSales measure and Year & Month columns from Calendar table & Sales from Global-Superstore table.

TOTALYTD Output

TOTALYTD Output

As you can observe in the screenshot above, it returns the running total for Year 2011 & 2012 sales separately.

Recommended Post: TOTALMTD DAX , TOTALQTD DAX



Hope you enjoyed the post. Your valuable feedback, question, or comments about this post are always welcome or you can leave us message on our contact form , we will revert to you asap.

Leave a Reply