Variables in Daml are immutable so you cannot change the value of totalPrimaryBene. But you can define a new variable:
let totalPrimaryBene' = if isPrimary then totalPrimaryBene + benePercent1 else benePercent2
In some cases, you can reuse the variable name and shadow the existing variable name. Note that this is still very different from mutation: You are still defining a new variable. You are just hiding the existing one within the scope you’re currently in. One case where that works is within a do block:
do totalPrimaryBene <- pure (if isPrimary then totalPrimaryBene + benePercent1 else benePercent2)
…