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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Answered

Filter on a amount of a related entity.

(0) ShareShare
ReportReport
Posted on by

I'm trying to get a report from customer filtered on related records for example, all customers which opened more then 100 cases during the last year, how can I achieve this, I tried with fetch-xml using aggregation since I wasen't able to filter on the aggregation, also note: both the customer and the related entity contains more than 5000 records.

I have the same question (0)
  • Verified answer
    mobeenmohsin Profile Picture
    on at

    Hi,

    Please find information to get large records using paging as mentioned in https://docs.microsoft.com/en-us/powerapps/developer/data-platform/org-service/page-large-result-sets-with-fetchxml.

    Best Regards,

    Mobeen

  • salmy Profile Picture
    on at

    Thanks for your response, I checked the link you posted, but I can't find how to filter on the amount of the retrieved records from the related records, as I wrote I only want to return the customers which had opened more than 100 cases in last year.

  • Verified answer
    Bipin D365 Profile Picture
    28,983 Moderator on at

    Hi,

    Have you tried creating a rollup field on Customer which will show count of Opened cases duing last year?

    Then use this filter in your fetchxml.

    Ohhh....We don't have option to filter Case records created during last year...

    I have tried writting below SQL code based on Account (OOB Entity) and Employee (Custom entity)-

    SELECT a.name FROM msft_employee
    
    INNER JOIN account AS a ON msft_employee.msft_company = a.accountid
    
    WHERE msft_employee.statecode = 0 AND msft_employee.createdon = lastxyears(1)
    
    group by a.name having COUNT(a.name)>=100

    I did try to see fetchxml with the help of SQL4CDS plugin in xrmtoolbox but it shows 3 fetchxml -

    markcarrington.dev/.../

    Please mark my answer verified if this is helpful!

    Regards,

    Bipin Kumar

    Follow my Blog: xrmdynamicscrm.wordpress.com/

  • salmy Profile Picture
    on at

    Thanks for the answer, it worked like a charm, and BTW I learned a lot of new things from your blogs, it's amazing.

  • Verified answer
    Bipin D365 Profile Picture
    28,983 Moderator on at

    Hello,

    I'm glad that it worked.

    Could you please mark my answer verified by clicking Yes under 'Did this answer your question?'

    Please mark my answer verified if this is helpful!

    Regards,

    Bipin Kumar

    Follow my Blog: xrmdynamicscrm.wordpress.com/

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Martin Dráb Profile Picture

Martin Dráb 58 Most Valuable Professional

#2
#ManoVerse Profile Picture

#ManoVerse 42

#3
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 38 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans