Skip to Content

sap.m.Table Summing up a column value

Hello All,

I have sap.m.Table with 10 Columns.

Now in that one column is Total Resultant Loss and another is Resultant Loss.

Now i want to display summed up value in Total Resultant Loss.

This sum should be done based on condition i,e if the column has same loss types and units should be summed up together and displayed in the first column and remaining columns should be empty.

Please find the attached Screen shot for more information.

Regards,

Shekar.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

2 Answers

  • Posted on Jul 11, 2016 at 06:59 AM

    Hi Shekar,

    The calculation will have to be done in code, best is to loop through your model and place the found values in a new JSON model, then bind it to your sum-controls.

    To display the sum of a column correctly, you can use a column footer, like so:

    <Column minScreenWidth="Tablet" demandPopin="true" hAlign="Left" width="4em">
      <Text text="{i18n>TableLabelUsed}"/>
      <footer>
      <Text text="{path: 'MockModelTotals>/LeaveTotalsLegalLeaveTableUsed', formatter:'hrstamgegevens.model.formatter.floatValue'}"/>
      </footer>
      </Column>
    
    

    Then it will display a footer, that shows the sum of the values.

    I hope this suits your scenario 😉

    Greets,

    Caspar

    PS: Check out this link for more info, and a JS example: Sum of values in each column in a table in sapui5 - Stack Overflow

    Add a comment
    10|10000 characters needed characters exceeded

    • Hello Casper,

      My requirement is to Sum up for only single column.

      But in that single column i need to add the values for specific Group.This is some thing siimilar to adding the values in items in a sales order.

      Here i need to sumup Total Loss Unit Column for every group and teh added value should only be displayed in first Row of the event.

      AddTotalLoss.jpg (166.2 kB)
  • Posted on Jul 11, 2016 at 07:39 AM

    Hi Mantri,

    Sorry, I was not aware your table was grouped.

    So far, this is not possible in SAPUI5 on a standard way.

    The only thing that is possible, is to display a footer in a column, which will be at the bottom of the table.

    If this is not what you need, but you need it per group, you'll have to custom build something. 😊

    Greets,

    Caspar

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.