---
schema_version: "1"
id: e96ea4dcc70e3a08d9b4afb230725fafb6b5a68e489d52101efa82a774f35857
title: Group by a Custom Fiscal Year
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/analytics/bi_dev_guide_saql/guides/reference/bi-saql-cfy-group.md
canonical_url: https://developer.salesforce.com/docs/analytics/bi-dev-guide-saql/guide/bi-saql-cfy-group.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 882754ea040ba279c4d1c621ff14346b7ebf8e01961c745ad69cd59ddbf19825
products:
  - Analytics SAQL Developer Guide
  - analytics
---

# Group by a Custom Fiscal Year

Here’s how to group by a custom fiscal year.

## Example

```nolang
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     |
