1

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?

1 Answer 1

0

Your requirement based on your description according to my understanding is:

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 src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js Jump "></script>
 <script>
 $(function () {
     ExecuteOrDelayUntilScriptLoaded(retrieveListItems, "sp.js");
 });
 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.load(collListItem);
     clientContext.executeQueryAsync(
     Function.createDelegate(this, this.onQuerySucceeded),
     Function.createDelegate(this, this.onQueryFailed)
     );

}
 function onQuerySucceeded(sender, args) {
     var listItemInfo = '';
     var listItemEnumerator = collListItem.getEnumerator();
     while (listItemEnumerator.moveNext()) {
         var oListItem = listItemEnumerator.get_current();
         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

2
  • the columns are 10, does it change something?
    – susan
    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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.