Calculate with NaN value in group

I used coalese() to deal with NaN in the form like this:
Book5.xlsx (10.8 KB)

I have a form with several groups. But the participant can answer for questions in only one group (based in some conditionals).
But the calculation always show NaN as the result, even I used coalesce()
Any walkaround for this?

Thank you so much!

@kienl, this should solve your issue:

Reference XLSForm:

Book5.xlsx (10.9 KB)