Sum a field on UITable based on the value on dropdown

195 Views Asked by At

I am creating an app which will perform some simple mathematical functions. One of these functions is to sum the field on my table. However, it should sum the field based on what is selected on the drop down menu and display the sum value on an edit field component. For instance, using the attached image, when I click control total, I would like to display the sum of the numbers in the fiscal period column and display it on the edit field on the right called sum.

function ControlTotalButtonPushed(app, event)
    ct = app.FieldsDropDown.Value;
    total = sum(app.UITable.Data.ct);
    app.EditFieldTotal.Value = total;
    if total == 0
        app.BalanceUnbalanceLabel.Text = 'Balance';
    else
        app.BalanceUnbalanceLabel.Text = 'Unbalance';
    end    
    end

I get an error:

Unrecognized variable name 'ct'

I thought app.UITable.Data.ct would refer to the column name to sum?

Please refer to the attached picture.

0

There are 0 best solutions below