Am new to coding , am trying to create a code that will multiply the self rating, excom rating and Mancom rating as seen in the code below . The code am sharing has not worked . Please help me get it right . Remember there two child tables . @ Usama_Naveed
total_rating_final = 0
for item in doc.kpi_structure:
# Validate inputs
if not all(isinstance(rating, (int, float)) for rating in [item.self_rating, item.mancom_rating, item.excom_rating]):
continue # Skip the item if ratings are not numbers
# Ensure weight is valid to avoid division by zero
if item.weight > 0:
total_rating_final += (item.self_rating + item.mancom_rating + item.excom_rating) / 3 * (item.weight / 100)
# Assign the final total to the document without rounding
doc.total_rating_final = total_rating_finaltype or paste code here