So far ist not clear, what kind of field your're using. And your script has some flaws or typos – see the comments.
var fields = xfa.resolveNodes("Table6.Row2[*].Cell1");
var total = 0;
// a property "formattedValueValue" does not exist
// What type of field is Cell1 – text or numeric?
for (var i=0; i <= fields.length-1; i++) {
total = total + fields.item(i).formattedValueValue;
}
// Is it "Table6.Row1.Cell" or "Table6.Row1.Cell1"?
// What type of field is it – text or numeric?
this.rawValue = Table6.Row2.instanceManager.count == 0 ? "(i) Item 1" + xfa.resolveNode("Table6.Row1.Cell").formattedValue
: "(i) itme1 " + xfa.resolveNode("Table6.Row1.Cell1").formattedValue + "\n(ii) item2 " + total;
However, I guess this should do the trick.
var oRow2Cells = xfa.resolveNodes("Table6.Row2[*].Cell1"),
oRow1Cell = xfa.resolveNode("Table6.Row1.Cell1"),
nTotal = 0,
i;
for (i = 0; i < oRow2Cells.length; i += 1) {
nTotal += parseFloat(oRow2Cells.formattedValue);
}
this.rawValue = "(i) Item 1" + parseFloat(oRow1Cell.formattedValue) + (oRow2Cells.length > 0 ? ("\n(ii) item2 " + nTotal) : "");