Group by a Custom Fiscal Year

Here’s how to group by a custom fiscal year.

Example

q = load "opportunities";
q = group q by 'CreatedDate_Year_Fiscal';
q = foreach q generate
   'CreatedDate_Year_Fiscal' as 'Fiscal Year',
   count() as 'count';
q = order q by 'CreatedDate_Year_Fiscal' asc;
q = limit q 2000;

The query returns:

Fiscal Year Count
2017 2
2018 1
2019 1
2020 1
2021 1
2022 1