How to get the number of Computers per installed Application?

I’m trying to create a report that produces a list of Windows Computer Applications (results of bes property "Installed Applications - Windows") and provides the number of computers that each application is installed on. After looking through old posts on this forum I found something similar to what I want and then made small alterations to it. The query does return a list of all the unique applications, but the computer count that it returns is zero for every one. I followed the logic of the query and from my perspective, it seems like it should work. Can someone help me to get this query working properly?

( item 0 of it, number of elements of item 1 of it ) of ( item 2 of it, sets of items 2 of ( item 0 of it, item 2 of it, elements of item 1 of it ) whose (value of results (item 0 of it, item 2 of it) = item 1 of it) ) of ( item 0 of it, item 1 of it, ( if (item 2 of it contains "%00") then (concatenation of substrings separated by "%00" of item 2 of it) else (item 2 of it) ) ) of ( item 0 of it, item 1 of it, unique values of values of (results (item 0 of it, elements of item 1 of it)) ) of ( it, set of members of bes computer groups whose (name of it = "Laptops") ) whose ( exist results (item 0 of it, elements of item 1 of it) whose (not error flag of it) ) of bes property "Installed Applications - Windows" whose (name of source analysis of it = "Application Information (Windows)")

I was able to create a report using just Web Reports without a custom query, if it is what you are looking for.

My web report has only two columns in it, one for Installed Applications-Windows and one for Count. If you edit the columns to expand the Installed Apps and to hide individual computers, I get a report such as:

Adobe Flash Player 30 ActiveX | 30.0.0.134 10 computers
IBM BigFix Client | 9.5.9.62 15 computers

Is that the type of report you are trying to create?

I’m using the BigFix REST API so it has to be done with a custom query.

We will likely need to refine this, but here is a start:

(it, multiplicity of it) of unique values of values of results from (bes property "Installed Applications - Windows") of bes computers

This will essentially return all values of all results from the property in question across all computers (though these elements are filterable), then count the number of unique values of the results (i.e. how many instances of a given result were found across all the results - which should generally equate to the number of computers per installed application in this case).