In this blog it's explained that how can we get distinct values from SharePoint List using JavaScript Client Object model and JQuery.
Below is code example that can be used when you need to get Count of Distinct values in a Column of SharePoint list. The example is using JavaScript Client Object model and Jquery.
Lets look at the method getDistinctItemsFromList(). You need pass the “Listname” and specify “ColumnName” in the code.
function getDistinctItemsFromList(Listname) {
try {
var context = new SP.ClientContext.get_current();
var list = context.get_web().get_lists().getByTitle(Listname);
var items = list.getItems();
context.load(items);
context.executeQueryAsync(
function () {
var itemCount = items.get_count();
var itemsarry = new Array(parseInt(itemCount) – 1);
var ListEnumerator = items.getEnumerator();
//adding values to array
for (i = 0; i < itemCount; i++) {
itemsarry[i] = new Array(0);
itemsarry[i][0] = items.get_item(i).get_item(ColumnName);
}
//gettig count of unique values from array

Join the conversation! Your thoughts help the community grow.