web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How can I show the Sum of a field row of a Grid on a form, just below the field.

(0) ShareShare
ReportReport
Posted on by 518

Hello all,

How can I show the Sum of a field row of a Grid on a form, just below the field. That is summarized value.

Month Ordinary Wages (OW) OW CPF Contribution (Employer) OW CPF Contribution (Employee) Ordinary Wages (AW) AW CPF Contribution (Employer) AW CPF Contribution (Employee)
JAN            
FEB            
MAR            
APR            
MAY            
JUN            
JUL            
AUG            
SEP            
OCT            
NOV            
DEC            
TOTAL  XXXXXXXXX  XXXXXXXXX  XXXXXXXXX  XXXXXXXXX  XXXXXXXXX  XXXXXXXXX

I am Referring this two documents but not very clear about On which control and where I should write code. http://dev.goshoom.net/en/2015/11/summarized-values-in-ax-form/   www.agrinei.com/.../gridviewhelper_en.htm

Thank You

Siddhant Singh

*This post is locked for comments

I have the same question (0)
  • Verified answer
    nmaenpaa Profile Picture
    101,172 Moderator on at

    The first blog is quite clear. Create a new method called updateTotal on your form, and call it from executeQuery method of the data source that you use in the grid.

    Your summarized field(s) is/are updated from the updateTotal method each time it executes.

    Does this help you forward?

  • Siddhant Singh Profile Picture
    518 on at

    Actually I have a problem in design part. Do I have to take a new control to show the summed values below the grid. If yes then which control I have to use and how can I like it with the code.

  • Verified answer
    Rohin Profile Picture
    4,624 on at

    Hey Siddhant, 

    I have similar requirements few days back and had implemented using the link you shared(Martin's blog). 

     You need to have all total controls ( in your case its 6) and write a new method on form similar to method on above link which basically build the query by sum and put the values into your total controls and then you will be calling this method on executeQuery of your datasource.

      I'm not sure what problem you facing . Would be better if you share something more about your problem.

  • Verified answer
    nmaenpaa Profile Picture
    101,172 Moderator on at

    Just add a new Group under your grid, and add 6 unbound real controls in it. Set property "Columns: 6" for your group and you should see the fields side by side.

    Set property AutoDeclaration: Yes for all your fields. Then you can set values to these fields from updateTotal method like you see in the example in Martin's blog.

  • Siddhant Singh Profile Picture
    518 on at

    Hello Nikolaos,

    One more thing which is required is

    As soon as the data entered in a grid of a form, it should also reflect in the sum of the grid row in the real control. Where and what should be the code to refresh the real control each time when the form is hit by user.

  • Suggested answer
    Rohin Profile Picture
    4,624 on at

    That's why you are calling this method in executeQuery() so when form open by user these controls gets the value. But if you want to update total values when you creating record on form ( on writing) call updateTotal() method on datasource write method after super call.

  • Siddhant Singh Profile Picture
    518 on at

    I have written code to call updateTotal() on datasource<write() . But its not working.

  • Suggested answer
    nmaenpaa Profile Picture
    101,172 Moderator on at

    It should update the totals when a record is saved. Does it not do that? What does it do?

    Did you place your code after the super call?

  • Siddhant Singh Profile Picture
    518 on at

    Its doing that but I want to update total values as soon as the record is entered in the grid on form. ( while writing the record on the form).

    Basically total record control reflect with sudden change in the grid value of a field.

  • Suggested answer
    nmaenpaa Profile Picture
    101,172 Moderator on at

    The UpdateTotals calculation is based on the data in the database, therefore it can't take your new record (which is not yet in the database) into account when calculating.

    But you can enhance the method to take into account also non-inserted record, and call the method whenever a field is modified (override the modified method of your data source field). But this would work only when you create a new record, it would not work when you update an existing record.

    if (myDataSourceTable.RecId == 0)
    {
        myTotal1Value += myDataSourceTable.MyField1;
    }


    You can even further enhance it so that the existing UpdateTotals calculation query would always skip the current active record (add a range to exclude the record that has MyDataSourceTable.RecId), and calculate the values from current active record separately into the summed values. This way you can always refresh the totals directly after the user has changed a field in the active record.

    In general this is not how the totals fields in the system work, but you can do it as you like.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 16

#2
GiacomoRovai Profile Picture

GiacomoRovai 4

#3
Douglas Noel Profile Picture

Douglas Noel 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans