The CreatorCon Call for Content is officially open! Get started here.

Get the Min score over the last 12 ROLLING months

ITA
Tera Contributor

Hello,

I have a requirement for a formula indicator that should retrieve the minimum % score of the last 12 months. The issue I'm facing is that in the analytics hub, it shows the MIN result, which is 82%, and this score is the MIN of 2022, not 2023, which has a result of 83%. I want to set it up so that if I choose the 2022 months, the MIN score remains 82%, and if I choose 2023, it should be 83%, and so on for subsequent years. Additionally, I need the score to be displayed instead of showing NO SCORE

Here is my formula script :

 

var year = score_start.getYear();
var day= score_start.getDayOfMonthLocalTime();
var lowestScore =100;

for (var month = 1; month <= 12; month++) {
    var monthStr = month.toString();
  if (month < 10) {
    monthStr = '0' + month; } 
else {
    monthStr = '' + month;
  }
  var dateStr = year + '-' + monthStr + '-' + day;

  var score = pa.getScore($[[My % indicator],new GlideDateTime(dateStr));

if (score < lowestScore) {
    lowestScore = score;
  }
}
 lowestScore;

 

Display for 2022 :

ITA_0-1700740346221.png

Display for 2023 :

ITA_1-1700741374143.png

 

 

 

Did I miss something in my script? Normally, I tried to loop through the 12 months of the year, format the date, add it to pa.getscore, return the minimum value for each month, and finally retrieve the lowest score.

 

0 REPLIES 0