9 Replies Latest reply on Jul 23, 2012 10:03 AM by Juracy Americo

# Would a function like InYearToDate() be useful to anyone?

I recently created a example workbook at The specified item was not found. that deals with current YTD and comparing to previous YTD.

Here is one of the calculations, that Sums the Amount for Last year's YTD:

```SUM(

IF DATEPART('dayofyear',[Date]) <= DATEPART('dayofyear',TODAY())
AND DATEPART('year',[Date]) = DATEPART('year',TODAY())-1
THEN [Amount] END)
```

Would it be useful to instead write:

```Sum(

IF InYearToDate ([Date], TODAY(), -1)
THEN [Amount] END
```

Or how about something like:

```Sum(

IF InPartToDate ('year', [Date], TODAY(), -1)
THEN [Amount] END
```

• ###### 1. Re: Would a function like InYearToDate() be useful to anyone?

Or how about if you just wanted to test if the date was in any year to date, leaving off the last argument:

```IF InPartToDate ('year', [Date], TODAY())

THEN "In any YTD" ELSE "After YTD" END
```

Could be most useful as a filter. To me, this seems more intuitive than

```IF DATEPART('dayofyear',[Date]) <= DATEPART('dayofyear',TODAY())

THEN "In any YTD" ELSE "After YTD" END
```

What do you think?

• ###### 2. Re: Would a function like InYearToDate() be useful to anyone?

+1 Joe

• ###### 3. Re: Would a function like InYearToDate() be useful to anyone?

Good idea Joe.

My only hesitation is that I would really prefer to have support for User Defined Functions, rather than just a slowly increasing set of built-in functions.  That would allow the TCRL idea to be replaced by a community contributed UDF library - which I'm sure Joe would have well stocked for us all within days.  ;-)

I know UDF support has been discussed before and is at least on the "dreams list" for the Tableau folk.

• ###### 4. Re: Would a function like InYearToDate() be useful to anyone?

Thats right Richard, this would be a perfect function as a UDF. Of course I would rater have a UDF option than this built-in.

• ###### 5. Re: Would a function like InYearToDate() be useful to anyone?

UDFs would be awesome

• ###### 6. Re: Would a function like InYearToDate() be useful to anyone?

+1 to everything Richard said, LOL!

But I, too, agree that UDF library would be groovy-cool.  To Joe's specific idea, no need now but with some of the requests I've seen I'm sure it would get used.  At my last job we would have used it at the week and month levels.

• ###### 7. Re: Would a function like InYearToDate() be useful to anyone?

+1 YTD, QTD, MTD

• ###### 8. Re: Would a function like InYearToDate() be useful to anyone?

+1

• ###### 9. Re: Would a function like InYearToDate() be useful to anyone?

+1