Date.IsInYearToDate
DateReturns true if the date falls between January 1 of the current year and today (inclusive).
Syntax
Date.IsInYearToDate(dateTime as any) as logicalParameters
| Name | Type | Required | Description |
|---|---|---|---|
dateTime | any | Yes | A date, datetime, or datetimezone value to test. |
Return Value
logical — true if the date falls from January 1 of the current year through today, false otherwise.
Remarks
Date.IsInYearToDate returns true if the input date falls between January 1 of the current year and today's date (inclusive), as determined by DateTime.LocalNow(). This differs from Date.IsInCurrentYear, which includes the entire year including future dates. Use this function for YTD metrics where you only want to compare the portion of the year that has elapsed.
This is a critical distinction for YTD vs. full-year comparisons. Date.IsInCurrentYear would include all of April through December even in March, while Date.IsInYearToDate stops at today. Always prefer Date.IsInYearToDate when computing KPIs against a YTD target.
The function is re-evaluated on each query refresh. In cloud environments (Power BI Service, Dataflows), "today" is determined by the server's UTC clock, which may cause YTD to cut off at a different point than your local time. For timezone-accurate YTD calculations, compute the boundary explicitly using DateTimeZone.LocalNow() and compare dates directly.
Examples
Example 1: Filter year-to-date sales
Table.SelectRows(
Sales,
each Date.IsInYearToDate([OrderDate])
)OrderID | OrderDate | |
|---|---|---|
| 1 | 38 | 1/10/2026 |
| 2 | 40 | 2/20/2026 |
| 3 | 42 | 3/8/2026 |
Example 2: Compare YTD vs. full current year flags
Table.AddColumn(
Table.AddColumn(
Sales,
"IsCurrentYear", each Date.IsInCurrentYear([OrderDate]), type logical
),
"IsYTD", each Date.IsInYearToDate([OrderDate]), type logical
)OrderID | OrderDate | IsCurrentYear | IsYTD | |
|---|---|---|---|---|
| 1 | 38 | 1/10/2026 | TRUE | TRUE |
| 2 | 42 | 3/8/2026 | TRUE | TRUE |
| 3 | 45 | 6/15/2026 | TRUE | FALSE |
Example 3: YTD total revenue
let
YTDSales = Table.SelectRows(Sales, each Date.IsInYearToDate([OrderDate])),
TotalRevenue = List.Sum(
Table.AddColumn(YTDSales, "Revenue", each [UnitPrice] * [Quantity], type number)[Revenue]
)
in
#table(type table [Metric = text, Value = number], {{"YTD Revenue", TotalRevenue}})The final output — a single-row table labeling the YTD revenue total.
Metric | Value | |
|---|---|---|
| 1 | YTD Revenue | 100 |