The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Bucket Group and Scripted Automated Indicator- Breakdown for empty vs. not empty

jlaps
Kilo Sage

Hello Community!

I am trying to create a breakdown for a group of existing indicators that will separate based on whether a field is empty or not. This is currently a text field, so it is not something I can use a normal breakdown for and have tried using a bucket group. I do not want to create additional indicators and stack them as there are many, and I am already doing some stacking- the breakdown method will be cleaner, but I think I am missing a step or just have a bad script.

I created a bucket group-

find_real_file.png

I created a breakdown source-

find_real_file.png

And finally I created an automated breakdown-

find_real_file.png

Unless I am missing a step, which is entirely possible, I think the problem is likely my script since I am a scripting neophyte- I have tried to create this based on what is OOB and some googling.

function empty() {
if (!u_peer_bundle)
	return '0';
else
	return '1';
}

When I run a collection, nothing is sorted into either the 0 or 1 buckets. Hoping it is something easy, or if someone has a better idea. Thanks!

Jeff

6 REPLIES 6

 Thanks Adam! I actually just got it working by tweaking the bucket group to have numerical gaps; I swear the 0-1 1-0 thing was giving me the opposite expected answers for a bit, so I gave them gaps. I also changed the script slightly though I am unsure if any of this was necessary. Pretty sure I was shotgunning the fixes and got lucky. Running the collections on all the indicators for final confirmation, but it is coming out how I want now.

 

var empty=function(x) {
	if (x == '')
	return '2';
else
	return '5';
};
empty(current.u_peer_bundle);

Adam Stout
ServiceNow Employee
ServiceNow Employee

Instead of

if (x == '')

use

if (gs.nil(x))

That will handle nulls as well.