Let's say that in 2013 and 2014 a business used trimesters, and then in 2015 it switched to quarters. How will queries that use the LAST N FISCAL QUARTERS literal work?
SELECT Id FROM Account WHERE CreatedDate = LAST_N_FISCAL_QUARTERS:8
Can I assume that this query, running during the first fiscal quarter of 2016, will return Accounts created during 2015 (4 fiscal quarters), 2014 (3 fiscal "quarters") and the last trimester of of 2013 (1 fiscal "quarter")?
Or will SOQL operate based on my "current" fiscal quarter settings? The documentation makes it sound like it'll be smart and return the results described above, but has anyone tried this?
Best Answer
Behavior
Here is my interpretation based on the evidence I have gathered (detailed below):
In light of this finding, it would be prudent to make sure your Custom Fiscal Years are always defined into the future.
Data
I created
MyObject__c
records with the followingDate__c
values (expected Quarter in parentheses):I would then query for the data as follows:
Preliminary Investigation
First, I set up trimesters just for 2013 and 2014.*
Sure seems like
LAST_N_FISCAL_QUARTERS:1
matches up with 2014-T3.Follow Up
After that I added 2015.
And finally 2016.
Looks like
THIS_FISCAL_QUARTER
is one quarter afterLAST_N_FISCAL_MONTHS:1
, in case that wasn't obvious.* This post prompted me to lay out in detail how to set up trimesters in the first place. How Do I Set Up Fiscal Trimesters, Anyway?