- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2017 02:12 AM
Hi Guys, I am pretty new to PA and very new to scripting. I am looking to exclude weekend from the formula indicator.
I guess I have to include GlideSchedule in the script but how?
Current OOB script:
var diff=function(x,y){return y.dateNumericValue() - x.dateNumericValue();};
var days=function(x,y){return diff(x,y)/(24*60*60*1000);};
days(current.opened_at, score_end);
Solved! Go to Solution.
- Labels:
-
Performance Analytics
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-20-2017 04:17 AM
The indicator is probably for triggering action on aging tickets.
I would not recommend looking at schedules, as things might get complex and hard to maintain.
Below script should exclude saturdays and sundays from the daycount.
Please try and let me know if it works
var diff=function(x,y){return y.dateNumericValue() - x.dateNumericValue();};
var businessDays = function(x,y){
var xx = new GlideDateTime(x);
var startDayOfWeek = xx.getDayOfWeek(); //11 = monday 7 = sunday
var ageDays = Math.floor(diff(x,y)/(24*60*60*1000)) || 0; //total day age
var withoutFullWeekendDays = ageDays - (Math.floor(ageDays / 7) *2); //for full weeks substract 2 days per week
var modDays = ageDays % 7; //remaining non full week days
var substractDays = Math.min(Math.max(0,(startDayOfWeek - 5) + modDays),2); // should work, between w2 days substract
return ( withoutFullWeekendDays - substractDays ) || 0;
};
businessDays(current.opened_at, score_end);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-11-2017 06:37 AM
Hi arnoud ,
Just found my indicator is incorrect where the summed age for resolved tickets shows -2 despite the collected jobs are correct...
I did some changes on the script by replacing score_end with current.resolved_at.
Could this be the reason of causing error above?
I am actually trying to find the sum days of resolved tickets.
The script:
The indicator:
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-12-2021 12:58 PM
How can you validate the data if this script has excluded weekends from the counts?
If my response helped you, please click on "Accept as solution" and mark it as helpful.
- Saloni
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2023 12:14 AM
Hi Arnoud,
Even after trying the above script I am still getting the age of incidents for all the days without excluding weekends. Could you let me know what might be the issue or is there any other way to achieve this?
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2023 02:42 AM
I assume you would like to exclude holidays and any other non-working day, too?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-06-2023 04:36 AM
Nope. I want to exclude only Weekends - Saturday and Sunday