Skip to main content
Skip table of contents

An alternative method for YTD & MTD calculations

Tableau has many date functions, MAKEDATE, DATEDIFF, DATEPART, DATEADD, DATETRUNC, DATENAME, that can be used in calculating YTD and MTD values.

An alternative that might be easier for some is to convert the date to a string field and use part of that for comparison. When Tableau converts dates to string values, it displays as yyyy-mm-dd, i.e., 06/15/2023 is converted to 2023-06-15. If you select 5 characters from the end, you get a common month-day format that is sortable and comparable. The Calculation is RIGHT(STR([Invoice Date]),5). 6/15/2023 would result in
06-15 for any year.

For YTD based on today’s date: RIGHT(STR([Inv Date]),5) <= RIGHT(STR(Today()),5)

For MTD based on today's date: RIGHT(STR([Inv Date]),2) <= RIGHT(STR(Today()),2)

For YTD based on a Parameter date: RIGHT(STR([Inv Date]),5) <= RIGHT(STR([DATE_PARAMETER]),5)

For MTD based on a Parameter date: RIGHT(STR([Inv Date]),2) <= RIGHT(STR([DATE_PARAMETER]),2)

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.