Relevance Nugget - First and Last

Hello team. As you may know, the order of return of objects for BigFix is dependent on the underlying OS and systems, so we cannot assure any specific ordering of return values. As a result, we do not really have the concept of the first or last object.

Example:

q:  display names of services
A: Adobe Acrobat Update Service
A: Intel® SGX AESM
A: AllJoyn Router Service

not Alpha sorted…
But you CAN get around it if you want the First and Last service names with a neat little trick of Concatenation plus Tuple String Items

For the First, it is pretty easy

q: tuple string item 0 of concatenation ", " of display names of services
A: Adobe Acrobat Update Service

for Last it is a little more tricky

q: tuple string item (number of tuple string items of it -1) of concatenation ", " of display names of services
A: Windows Push Notifications User Service_3437a7

Enjoy!

4 Likes

Just to add to this a bit…if you’re going to use this generically, I’d encourage using the “tuple string of” inspector instead of ‘concatenation ", " of’. Because ‘tuple string’ will handle cases where the strings already have embedded commas, by escaping them in a way that ‘tuple string items’ recognizes.

q: ("To be, or not to be, that is the question:"; "Whether 'tis nobler in the mind to suffer"; "The slings and arrows of outrageous fortune,")
A: To be, or not to be, that is the question:
A: Whether 'tis nobler in the mind to suffer
A: The slings and arrows of outrageous fortune,
T: 0.611 ms
I: plural string

q: tuple string of ("To be, or not to be, that is the question:"; "Whether 'tis nobler in the mind to suffer"; "The slings and arrows of outrageous fortune,")
A: ( To be, or not to be, that is the question: ), Whether 'tis nobler in the mind to suffer, ( The slings and arrows of outrageous fortune, )
T: 0.576 ms
I: singular string

q: tuple string item 0 of tuple string of ("To be, or not to be, that is the question:"; "Whether 'tis nobler in the mind to suffer"; "The slings and arrows of outrageous fortune,")
A: To be, or not to be, that is the question:
T: 0.495 ms
I: singular string

q: tuple string item (number of tuple string items of it - 1) of tuple string of ("To be, or not to be, that is the question:"; "Whether 'tis nobler in the mind to suffer"; "The slings and arrows of outrageous fortune,")
A: The slings and arrows of outrageous fortune,
T: 0.409 ms
I: singular string

In the Services list above, I think the alphabetical order is not guaranteed…I think the inspector is retrieving the services in order of service name while you are retrieving the display name of the services, so in many cases the order is the same; I think the “Intel SGX AESM” service probably has an internal service name of “AEMS” and hence was sorted between Adobe and Alljoyn. But to guarantee a sorted order we can use ‘unique values of (string)’.

q: unique values of ("To be, or not to be, that is the question:"; "Whether 'tis nobler in the mind to suffer"; "The slings and arrows of outrageous fortune,")
A: The slings and arrows of outrageous fortune,
A: To be, or not to be, that is the question:
A: Whether 'tis nobler in the mind to suffer
T: 0.290 ms
I: plural string with multiplicity

Combining the two, we can guarantee retrieving the last string in sorted alphabetical order

q: tuple string item (number of tuple string items of it - 1) of tuple string of unique values of ("To be, or not to be, that is the question:"; "Whether 'tis nobler in the mind to suffer"; "The slings and arrows of outrageous fortune,")
A: Whether 'tis nobler in the mind to suffer
T: 0.173 ms
I: singular string
3 Likes