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 :
Customer experience | Sales, Customer Insights,...
Suggested Answer

get Sum of amount field from Child entity via Fetch XML

(0) ShareShare
ReportReport
Posted on by 144

I need to fetch child entities along with the SUM of a field 'amount' from all child records (of a particular parent record). For E.g. If there are 3 child records for a parent record, so need to have SUM of all 3 different amount values of each child record. Also, the SUM needs to be calculated for the child records where it meets certain criteria. I already tried adding aggregate along with filter condition (so that my aggregate would be applicable on filtered records only), but it did not work. Please suggest.

TIA.

I have the same question (0)
  • David Jennaway Profile Picture
    14,065 on at

    This should be possible. Can you post the fetchXml that you have so far, and an example of the results ?

  • Suggested answer
    Joana Pinto Profile Picture
    740 on at

    Hi,

    So I've made an example on my own, with the following fetchxml:

        
            
            
                
            
            
                
            
        
    

    And I think this is you scenario. I have an Account that has a 1:N relationship with Lead entity. So I've done a fetch that makes the sum of the "estimatedamount" field on every lead related to that Account. My result was the following:

    <resultset morerecords="0">
    <result>
    <name>Joana Pinto</name>
    <amount formattedvalue="€4,654.01">4654.01</amount>
    </result>
    </resultset>

    You have to put on the beginning the aggregate="true" and then put the aggregate="sum" on the field you want to sum.

    Regards,

    Joana

  • snehaln676 Profile Picture
    144 on at

    I have a scenario where I have to retrieve data from child entity using fetchxml. Example: I have few child records having an attribute 'Role' with values RoleA, RoleB, RoleC (which is an Optionset) and another attribute as Amount(textfield). I want to get sum of amount for those records having value 'RoleB'. Please help me with the filter condition.

  • Suggested answer
    Joana Pinto Profile Picture
    740 on at

    Hi,

    You just need to add the filter condition that you want on the link entity. In my case, my related record is Lead records and I put a condition saying that I only want the sum of Leads that are Open (status field). Like this (line 10):

        
            
            
                
            
            
                
                
                    
                
            
        
    

    If you still have doubts please, provide your fetchxml so we can help you.

    Thanks.

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 April Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 69 Most Valuable Professional

#2
ManoVerse Profile Picture

ManoVerse 60 Super User 2026 Season 1

#3
11manish Profile Picture

11manish 43

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans