Tableau function Date

Tableau ISOYEAR to SQL

ISOYEAR(date) returns the year that the date's ISO week belongs to. It differs from the calendar year only in the first or last days of a year: 1 January 2021 is ISO year 2020, and 30 December 2024 is ISO year 2025. In DuckDB use isoyear().

Updated · Checked on the xmetric engine

What is the syntax?

ISOYEAR(date)
date
a date or date-time.

Returns an integer: the ISO 8601 week-based year. Null if the date is null.

What does it return, and what is the SQL?

Each example runs on the same 9 sample rows twice: the Tableau formula on the xmetric engine, and the SQL in DuckDB.

Which ISO year does each order belong to?

Tableau

ISOYEAR([Ordered])

SQL (DuckDB)

SELECT isoyear(Ordered) AS result
FROM input
ORDER BY id

Orders 1 and 2 return 2020; order 5 on 30 December 2024 returns 2025.

OrderedResult
2021-01-01 08:002,020
2021-01-03 18:452,020
2024-02-29 10:152,024
2024-12-29 16:25:402,024
2024-12-30 09:052,025
2025-01-31 23:59:592,025
2025-03-01 00:002,025
2025-03-02 12:30:152,025
null

The Tableau formula and the SQL return the same 9 rows.

Which orders have an ISO year different from their calendar year?

Tableau

ISOYEAR([Ordered]) <> YEAR([Ordered])

SQL (DuckDB)

SELECT isoyear(Ordered) <> year(Ordered) AS result
FROM input
ORDER BY id

True for orders 1, 2 and 5: the first days of 2021 and the last Monday of 2024.

OrderedResult
2021-01-01 08:00true
2021-01-03 18:45true
2024-02-29 10:15false
2024-12-29 16:25:40false
2024-12-30 09:05true
2025-01-31 23:59:59false
2025-03-01 00:00false
2025-03-02 12:30:15false
null

The Tableau formula and the SQL return the same 9 rows.

Where does a straight translation go wrong?

Common mistake

Why does year() disagree with ISOYEAR around New Year?

year() is the calendar year. Orders 1 and 2 (1 and 3 January 2021) are in ISO week 53 of 2020, and order 5 (30 December 2024) is in ISO week 1 of 2025.

Tableau

ISOYEAR([Ordered])

Tempting SQL

SELECT year(Ordered) AS result
FROM input
ORDER BY id

SQL that matches

SELECT isoyear(Ordered) AS result
FROM input
ORDER BY id
OrderedTableauTempting SQLSQL that matches
2021-01-01 08:002,0202,0212,020
2021-01-03 18:452,0202,0212,020
2024-02-29 10:152,0242,0242,024
2024-12-29 16:25:402,0242,0242,024
2024-12-30 09:052,0252,0242,025
2025-01-31 23:59:592,0252,0252,025
2025-03-01 00:002,0252,0252,025
2025-03-02 12:30:152,0252,0252,025
nullnullnull

The SQL that matches returns the Tableau result on every row; the marked cells are where the tempting SQL differs.

How do I write it in Snowflake or BigQuery?

The first example, written for each warehouse from its documentation. These are not run here; DuckDB is.

Snowflake

SELECT YEAROFWEEKISO(Ordered) AS result
FROM input
ORDER BY id

Snowflake documentation

BigQuery

SELECT EXTRACT(ISOYEAR FROM Ordered) AS result
FROM input
ORDER BY id

BigQuery documentation

What does your own ISOYEAR formula return?

Edit the formula and run it on the 9 sample rows. Fields: [id], [Ordered], [Due], [Text], [Local], [Y], [M], [D].

Runs in your browser on the xmetric engine. Nothing is uploaded.

Which functions go with it?

What do people ask about ISOYEAR?

When should I use ISOYEAR instead of YEAR?

Whenever you group or label by ISO week. A week number only makes sense next to its ISO year; with the calendar year, the weeks around New Year get the wrong year.

Which days change year?

Up to three days at each end of a calendar year. ISO year 2025 starts on Monday 30 December 2024; ISO year 2020 runs until Sunday 3 January 2021.

What does ISOYEAR return for a null date?

Null, in Tableau and in SQL.

Where is this documented?