# Calculated columns: count number of times a word is selected in a 8 column list

I have the following types of calculations on 8 choice columns with always the same values High, Medium and Low.

If there are 2 entries of High, the column should say High, if there are 4 entries marked Medium it is Medium and if only 2 categories are marked medium it is Low.

Is there another way to do this also without calculated columns?

High >=2    -->  High
High <2 & Medium >=4  -->  Medium

However, I cannot understand why “if only 2 categories are marked medium it is Low”.

As you have 8 choice columns, it should be

High <2 & Medium < 4 -->  Low

To achieve that, an easier method is use some calculated columns with IF function to find out how many times particular text occurs in these choice columns.

1. Create a calculated column named “NumberOfHigh”.
2. use the following formula:

=IF([column1]="High",1,0)+IF([column2]="High",1,0)+….

3. Save the column. After that, you will get the number of “High” values.

4. Repeat the 1-3 steps to count the “Medium” and “Low” values.
5. Create a calculated column with the formula below, to get the “High”, “Medium” or “Low” result.

=IF([NumberOfHigh]>=2, "High", IF([Medium]>=4, "Medium", "Low"))

Without using the calculated column, you need to use JSOM to retrieve list item and check these choice columns values of the item and count the number of “High”, “Medium” and “Low”. Set the column based on the number of “High”, “Medium” and “Low”.

Demo of retrieving list items:

<script>
\$(function () {
});
function retrieveListItems() {
var clientContext = new SP.ClientContext();
var oList = clientContext.get_web().get_lists().getByTitle('<list>');
var camlQuery = new SP.CamlQuery();
this.collListItem = oList.getItems(camlQuery);
clientContext.executeQueryAsync(
Function.createDelegate(this, this.onQuerySucceeded),
Function.createDelegate(this, this.onQueryFailed)
);

}
function onQuerySucceeded(sender, args) {
var listItemInfo = '';
listItemInfo += 'ID: ' + oListItem.get_id() +
'Title: ' + oListItem.get_item('Title');
}
console.log(listItemInfo);
}
function onQueryFailed(sender, args) {
alert('Request failed. ' + args.get_message() +
'\n' + args.get_stackTrace());
}
</script>

Refer to:

SharePoint Online: Retrieve list items from SharePoint list using JavaScript Object Model (JSOM)

How to: Create, Update, and Delete List Items Using JavaScript

• the columns are 10, does it change something? May 9, 2018 at 10:09
• It changes your conditions. You need to check 10 values instead. In addition, there should be no change. May 10, 2018 at 1:13