Monthly Job/Indicator calculating from first day of previous month, not last

Chris W1
Tera Expert

Hi Everyone,

Hopefully this is me making a basic error and not being able to find it, hope someone can help me find it.

I'm creating a monthly metric on the number of incidents that are more than 14 days old at the end of the month but when i run the collection job, it' using the first day of the month to count back the 14 days from and hence is moving the scores back by one month, so for example, the records for "February" are showing incidents that were more than 14 days old on 2/1, not on 3/1. 

Here's my indicator source:

find_real_file.png

 

And here's my collection parameters in the job:

find_real_file.png

 

 

And here's a view of the records collected for February, showing that the 14 days being used is from 1/31, not 2/28:

find_real_file.png

I've tried applying the 14 condition on the indicator not the indicator source, that didn't make any difference to the outcome. I've tried a myriad of different combinations of relative start and end dates with no different outcome either

If anyone can tell me how to get this to use 3/1 instead of 2/1 as the February date, I'd be incredibly grateful. Thanks.

 

(Also open to workarounds like grabbing a daily score from the last day of the month and automating dumping that into a manual indicator, because doing that manually is my current backup plan.)

1 ACCEPTED SOLUTION

Adam Stout
ServiceNow Employee
ServiceNow Employee

I can see a few options

  • Run this daily then use a formula indicator to only display the value from the last day of the month. I think we covered this in an Analytics Academy on advanced formulas.
  • Potentially report on SLAs duration instead of the incident themselves.  Then the query won't care about the date (although the time the job runs is very important now).

View solution in original post

7 REPLIES 7

thankyou so much for replying! Will investigate both options. Much appreciated.

following up on this, months later, mostly just to give a huge appreciative shout out and thanks to @Adam Stout for the answer here and the additional info he provided on the Analytics Academy Q&A on May 4th, which included the formula to set this up, which I'm copying here for posterity should anyone ever search and find this post.

Adam, this is saving me a bunch of time and effort and I literally could not have done this without you. Your dedication to helping people in this community is really cool and such a huge boon for everyone here. My PA journey has benefited a bunch from your expertise. I hope to make it to Knowledge again someday so I can thankyou in person For now: Thankyou!!

This is the formula Adam gave me, which is doing what I needed. And as he noted in the Q&A session, this is setup using a daily indicator. Every day of the month shows the same score, so the widget is set to show as a time series AVG by Month for a monthly socre 

Formula:

var lastDayInPeriod = new GlideDateTime(score_start.getYear() + '-' + score_start.getMonth() + '-01');

lastDayInPeriod.addMonthsUTC(1);

lastDayInPeriod.addDaysUTC(-1);

pa.getScore($[[indicator_name]], lastDayInPeriod);

SAI_JAGADEESH15
Tera Contributor

Hello guys,
I had created everything and I am getting the results too.
But it is not updating daily because of that I am creating new indicators again and again and updating those in formula indicators do you have any solution for this.