Dates Outside Ranges Defined by Custom Fiscal Year

If your query includes a date that falls outside of a range defined by an inherited fiscal year, SAQL does not return data for that date.

If a date falls outside of a range defined by an inherited custom fiscal year from Salesforce, then SAQL returns null for that date. When grouping by a date field that includes dates outside a range defined by an inherited custom fiscal year, no group is returned for undefined dates. If you group data based on non-fiscal periods, dates that aren’t included in a custom fiscal year return data as expected.

Example 

If your fiscal year ends in March 2021, and a date field, CreatedDate, is in April 2021, grouping by CreatedDate_Month_Fiscal returns null or no group for April 2021. Grouping by CreatedDate_Month returns data as expected.

Consider this example dataset.

Opportunity NameCreated DateAmount
Widgets2/1/2017100
Widgets2/1/2018100
Widgets2/1/2019100
Widgets2/1/2020100
Widgets2/1/2021100
Widgets2/1/2022100
Widgets2/1/2023100

In Salesforce, you have custom fiscal years defined as January 1 to December 31 for each year from 2018 through 2022. Inherit them in Analytics by using the Start Date setting.

When running a query like this:

1q = load "opportunities";
2q = foreach q generate 'CreatedDate' as 'Created Date', CreatedDate_Year_Fiscal as 'Fiscal Year';
3q = limit q 2000;

SAQL returns these results:

Created DateFiscal Year
2/1/2017-
2/1/20182018
2/1/20192019
2/1/20202020
2/1/20212021
2/1/20222022
2/1/2023-

Because a custom fiscal year definition doesn’t include 2/1/2017 or 2/1/2023, SAQL returns null.

Now, let’s group the dataset.

1q = load "opportunities";
2q = group q by 'CreatedDate_Year_Fiscal';
3q = foreach q generate 'CreatedDate_Year_Fiscal' as 'Fiscal Year', count() as 'Count';
4q = order q by 'CreatedDate_Year_Fiscal';
5q = limit q 2000;

SAQL returns these results:

Fiscal YearCount
20181
20191
20201
20211
20221

Since the custom fiscal year definition doesn’t include 2/1/2017 or 2/1/2023, the query excludes these dates from the results.