Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Formula that checks drop down list and then sums

Avatar

Level 3

I have a table with a drop down list with two values: '$' and 'Hr' (cell called 'PType').  There is a cell called 'Proposed' that contains numerical data. The table is dynamic and can have more cells inserted via a button within the row.  I have a totals section that I want to total the SUM of 'Proposed' if the value in 'PType' is '$'.  I can't figure out what type of statement will allow me to write this.

For now, my solution has been a hidden column whose cell simply states:

if (PType == "$") then
    Proposed
endif

Then, in the totals section, I sum this hidden column since a value outside of '$' returns a '0' and won't affect my SUM.

I am looking for a formula I can write that does this within the totals cell instead of having two cells.

Thanks,

Mallard27

1 Accepted Solution

Avatar

Correct answer by
Level 10

Here's my take on it.

// form1.page1.subform1.table.footer.SUM::calculate - (JavaScript, client)

var total = 0;

for (i=0; i < form1.page1.subform1.table._row.count; i++) {
    if (table.resolveNode("row[" + i + "].Proposed").rawValue) {
        if (table.resolveNode("row[" + i + "].PType").rawValue == "$") {
            total = total + parseFloat(table.resolveNode("row[" + i + "].Proposed").rawValue);
        }
    }
}

this.rawValue = parseFloat(total);

Steve

View solution in original post

0 Replies

Avatar

Correct answer by
Level 10

Here's my take on it.

// form1.page1.subform1.table.footer.SUM::calculate - (JavaScript, client)

var total = 0;

for (i=0; i < form1.page1.subform1.table._row.count; i++) {
    if (table.resolveNode("row[" + i + "].Proposed").rawValue) {
        if (table.resolveNode("row[" + i + "].PType").rawValue == "$") {
            total = total + parseFloat(table.resolveNode("row[" + i + "].Proposed").rawValue);
        }
    }
}

this.rawValue = parseFloat(total);

Steve

Avatar

Level 2

Is it possible to have a pre-made table already?  I tried the code you provided however in my case, I do not have the "add row" button.  I already have a table with 20 rows with an amount column and a dropdown column.