0

Can anyone please help !! Im using a 2x SharePoint Online lists. One list contains a REGISTER One list contains a list of ACTIONS to be taken against items on the REGISTER list I have managed to create the lookups as I wanted and show the % complete for each action. What Im struggling with is how to use the existing date and create JSON to show the average per item on the REGISTER. eg in the screenshot item Register item one has two actions one 20% complete and one 100% complete. I want the column "Overall Completion" to show 60% for the first list item and 20% for the second list item.

enter image description here

1 Answer 1

0

Assuming your JSON structure is like this:

let register = {
  "item1": [{"action1": 20}, {"action2": 100}],
  "item2": [{"action1": 20}, {"action2": 20}]
};
for (let item in register) {
  let total = 0;
  let actions = register[item];
  for (let i = 0; i < actions.length; i++) {
    for (let action in actions[i]) {
      total += actions[i][action];
    }
  }
  let average = total / actions.length;
  console.log(`Overall Completion for ${item}: ${average}%`);
}

Try this and let me know if it works for you.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.