Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Modification in the age of the bar graph of the report

JayasuryaJ
Kilo Contributor

Hi,
We have a requirement wherein we want to modify the X axis of the report. So far we have a graph showing aging tickets greater than 2 months but we need to differentiate among those tickets like tickets age from 2 months to 3 months , 3 months to 4 months and so on. Please refer to attached image.

2 REPLIES 2

JayasuryaJ
Kilo Contributor

JayasuryaJ_0-1720535543694.png

 

Yashsvi
Kilo Sage

Hi @JayasuryaJ,

1.Create a Calculated Field:

Business Rule script:

 

(function executeRule(current, previous /*null when async*/) {
    var ageInDays = gs.daysAgo(current.opened_at);
    if (ageInDays > 60 && ageInDays <= 90) {
        current.u_age_interval = '2-3 Months';
    } else if (ageInDays > 90 && ageInDays <= 120) {
        current.u_age_interval = '3-4 Months';
    } else if (ageInDays > 120 && ageInDays <= 150) {
        current.u_age_interval = '4-5 Months';
    } else if (ageInDays > 150) {
        current.u_age_interval = 'Over 5 Months';
    } else {
        current.u_age_interval = 'Less than 2 Months';
    }
    current.update();
})(current, previous);

 

2.Create or Modify the Report:

  • Go to the Reports module.
  • Create a new report or modify the existing one.
  • Set the type of report to a bar chart or a similar type that allows X and Y-axis customization.
  • Set the data source to the table where your tickets are stored (e.g., incident).
  • For the X-axis, select the newly created u_age_interval field.
  • For the Y-axis, you can select a count of the tickets.

3.Group and Aggregate Data:

  • In the report configuration, ensure you are grouping by the u_age_interval field.
  • Use the count aggregation to show the number of tickets in each aging interval.

4.Run and Save the Report:

  • Run the report to visualize the tickets grouped by the aging intervals.
  • Save the report for future use and share it with the relevant stakeholders.

Thank you, please make helpful if you accept the solution.