Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

YTD and MTD results

jsteele
Kilo Contributor

Our team is attempting to produce an indicator that calculates the 'average number of incidents created per day for a given month', and the 'average number of incidents created per day for a given YEAR'.   Requirements stipulate that we need to display both the MTD and YTD scores,   and historical monthly/yearly results.

For the MTD indicator, this was easy enough to accomplish with the getDate command:

var d = new Date();

([[INC-Count of SEV1 Incidents Created_daily / By month SUM +]] / d.getDate())

For YTD this wasn't too difficult although there may be better way(s):

var d0 = new Date(2018,0,1);

var d1 = new Date();

var days = Math.ceil((d1-d0)/8.64e7);

([[INC-Count of SEV1 Incidents Created_daily / By year SUM +]] / days)

Obviously these will only work for the current month/year, all prior months/yearly results would be incorrect.   Any advice on how I can code for the Monthly and Yearly historical results?   I could just populate a score sheet manually with historical data and populate that every month (and once a year), but there must be a more automated solution.   A solution that would calculate by MTD AND HISTORIC results would be ideal, that would simply maintenance down the road.   Thanks in advance for any advice!

-JS

---update----

I solved for this by creating a manual monthly indicator that just contains the number of calendar days in each month.   Then a simple formula indicator like this:

([[INC-Count of SEV1 Incidents Created_daily / By month SUM +]] / [[INC - Count of Days In Month]])

While maybe not the best solution, this seems to work ok for our purpose.   I will just display the YTD and MTD numbers in separate widgets.

Message was edited by: Jared Steele

2 REPLIES 2

Adam Stout
ServiceNow Employee
ServiceNow Employee

Why don't the time MTD and YTD time aggregate give you this?



Time series aggregations in scorecards and widgets


I couldn't get that to work originally, let me try again and get back.