Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 82002

Count similar records in FetchXML

$
0
0

Hi Community,

I'm facing problem counting similar records in fetchxml, please refer below FetchXML query.

<fetch distinct="false" mapping="logical" output-format="xml-platform" version="1.0" aggregate="true" >
    <entity name="quote" >
        <attribute name="quoteid" groupby="true" alias="quote" />
        <attribute name="indusa_productsg1" aggregate="count" alias="count" />
        <attribute name="indusa_grandtotal" aggregate="sum" alias="GrandTotal" />
        <filter type="and" >
            <condition attribute="indusa_grandtotal" operator="not-null" />
            <condition attribute="indusa_productsg1" operator="in" >
                <value uitype="product" uiname="Doors" >
                    {8490094E-5948-E611-80E6-3863BB36CDA8}
                </value>
                <value uitype="product" uiname="Roofing" >
                    {0909652C-7640-E711-810D-E0071B66CFF1}
                </value>
                <value uitype="product" uiname="Service" >
                    {0B09652C-7640-E711-810D-E0071B66CFF1}
                </value>
                <value uitype="product" uiname="Siding" >
                    {0709652C-7640-E711-810D-E0071B66CFF1}
                </value>
                <value uitype="product" uiname="SunRoom" >
                    {0509652C-7640-E711-810D-E0071B66CFF1}
                </value>
                <value uitype="product" uiname="Windows" >
                    {E5CBCF39-78F3-E611-80FC-3863BB360C20}
                </value>
            </condition>
        </filter>
    </entity>
</fetch>

Here I'm filtering quotes based on product group, so I want to count number of records for Doors, Siding, Service, SunRoom, Windows and Roofing and also want the sum of the Grand Total grouped by Doors, Windows, etc.

So, the output will show me something shown in below screenshot.

Please suggest the ways to achieve the same.

Thanks,

Hardik Chauhan


Viewing all articles
Browse latest Browse all 82002

Latest Images

Trending Articles



Latest Images