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

Count distinc not counting null as unique value

lucaalthoff
Tera Contributor

Hello ServiceNow Community,

 

I’m working on creating a scripted indicator that should return null if a specific condition isn’t met.

 

However, I’ve encountered an issue: the count distinct function still considers null as a unique value, which results in every null entry being displayed as 1 in the visualization.

 

Is there a way to make count distinct ignore entries with null values entirely?

11 REPLIES 11

Hi @Chaitanya ILCR,

Thanks for your comment. Unfortunatly it´s still not wortking. I think maybe some more informations from my side could help understand my problem. So Im trying to create an automated indicator with that Indicator Source: Screenshot 2025-09-05 142855.png

 The automated Indicator Source looks like that: 

Screenshot 2025-09-05 143026.png

 With the script I want to check, the incidents with no assignment group changes. I work with count distinct here because it can happen, that an incident has two entries with identical assignment groups.

 

But as mentioned before, count distinct always counts my null return as unique value. 

As you can see here, only these two incidents should be counted, but instead it counts as 3:

Screenshot 2025-09-05 143535.png

 

(I already tried 0;null;"";-1; as return value and in the "value when nil" field)

 

 

WillieW
Tera Contributor

@lucaalthoff 

I see a script in this thread defining a function named 'checkCurrentConsistency'. And on your indicator source screenshot, the Script field shows 'First Assignment Group'. Seems confusing.