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 CRM (Archived)

FetchXML - Only display the records that have the following criterias - is it possible?

(0) ShareShare
ReportReport
Posted on by 886

Hi,

Is it possible to create a fetchXML that will only display records per day (crm_date) where the count of crm_flag1 and crm_flag 2 that is set to yes is greater than or equal to 4? Also it should take the date into condiseration when performing the logic. So the logic is run per date. The entity name is crm_timeregistrations. 

Record set 1
This will display the first 2 records. It will be displayed because on 07-01-2019 there is 2 x crm_flag1=yes and 2 x crm_flag2 = yes. So in total 4 x yes for 07-01-2019. Record 3 will not be displayed because it's another date and there is less than 4 yes. 

crm_date: 07-01-2019, crm_flag1=yes, crm_flag2 = yes
crm_date: 07-01-2019, crm_flag1=yes, crm_flag2 = yes
crm_date: 08-01-2019, crm_flag1=no, crm_flag2 = no

Record set 2
Nothing will be dispalyed. There is only 1 x crm_flag1= yes and 1 x crm_flag2 = yes. So in total 2 x yes. 

crm_date: 09-01-2019, crm_flag1=yes, crm_flag2 = yes
crm_date: 09-01-2019, crm_flag1=no, crm_flag2 = no
crm_date: 10-01-2019, crm_flag1=no, crm_flag2 = no

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Guido Preite Profile Picture
    54,086 Moderator on at

    imho is not possible, you can't count the occurrences before showing the results and there isn't a fetchxml operator to allow that

  • Martin Donnelly Profile Picture
    1,030 on at

    I'm with Guido.  You can do aggregate fetches but, you can't combine list and aggregation; you can't use an aggregated value in a filter statement.  Nor can you send a variable to a TOP specification.

    Fetch works only with hierarchical joins.  There is no notion of the SQL joining to a "sub-select".  You show no relationship between your two entities.

  • Martin Donnelly Profile Picture
    1,030 on at

    ...of course, that being said, you may be able to build your filter expression dynamically in jscript and apply it to your sub-grid -- formContext.getControl("nameOfGridControl").addCustomView()

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 > 🔒一 Microsoft Dynamics CRM (Archived)

#1
ScottDurow Profile Picture

ScottDurow 2

#2
GJones Profile Picture

GJones 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans