How can a report be built to show the previous full 3 months?

Blair5
Tera Guru

Seems like a simple request but I'm having trouble getting the previous full 3 months. Using these conditions:

Created <relative> at or after 3 months ago AND

Created <before> this month

I am getting November (partial), all of Dec and all of Jan. Missing some of Nov. 

1 ACCEPTED SOLUTION

Dennis R
Tera Guru

Try using Created at or after Last 3 months instead. That should get you from the start of three months ago, instead of today's date minus three months.

find_real_file.png

View solution in original post

4 REPLIES 4

Dennis R
Tera Guru

Try using Created at or after Last 3 months instead. That should get you from the start of three months ago, instead of today's date minus three months.

find_real_file.png

So simple! Thank you 🙂 

Dennis R
Tera Guru

As a side note for anyone running across this question but who might want a report with some arbitrary number of months ago that isn't in that list (for example, say, 7 months), it's still doable, though you'll need access to run a background script in your instance.

 

To do so, find the sys_id of your report and substitute it for the one I have below that starts with "9c6b6b...". Also substitute the number of months for 7, or use any of the GlideSystem functions to get the time frame you're looking for. Run the background script below, and voila, you're good to go. Unfortunately, the condition builder won't let you specify javascript functions such as the one below, so you're stuck doing it through a back-end background script. Anyway, here's the script:

 

var reportSysId = '9c6b6be7dbb2889c1cd8a345ca961959'; // Substitute your own report sys_id
var grReport = new GlideRecord('sys_report');
if (grReport.get(reportSysId)) {
    grReport.filter = 'sys_created_on>=javascript:gs.monthsAgoStart(7)^EQ^ORDERBYsys_created_on';
    grReport.update();
}

 

If you want other conditions on your report, such as filtering by active records, created before a date, ordering by assignment group, or other such tweaks, my advice is to go ahead and design the report using a hard-coded date, then looking in the sys_report table to get the existing filter, then substituting any necessary javascript: calls to replace your hard-coded values.

 

Hope this helps,
--Dennis R

Hi @dennis,


Thanks for the script. This is working good but I have two data sets in the same report then please reply how can I overcome this question.?