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)

Getting distinct values from fetchXML using Liquid

(0) ShareShare
ReportReport
Posted on by 25

I have a fetchXML that returns data like this 

sample-data.PNG

wondering if I can get distinct group IDs using the same fetchXml by using some filter or otherwise have to write a separate query to get distinct groups?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Adrian Begovich Profile Picture
    1,027 Moderator on at

    Hi Usmani,

    Use this syntax in your Fetch XML definition.

    fetch mapping='logical' distinct='true'>
  • Verified answer
    oliver.rodrigues Profile Picture
    4,052 on at

    do you need the list Groups or you just to render as a group

    if you need the list perhaps the easiest way is repeating the fetch only retrieving the GroupId and adding the distinct as per Adrian indication

    if your looping and want to render as a group, I would suggest simply storing in a variable the last GroupId and keep verifying if it has changed

    worst case scenario you can do 2 fetchs.. one for the groups.. while looping, another fetch filtering by the group.. but this will decrease the performance

  • Verified answer
    Inogic Profile Picture
    756 on at

    Hi Usmani,

    “if I can get distinct group IDs using the same fetchXml by using some filter” – No, you cannot filter it using Fetch XML.

    You have to write separate query to get distinct group.

    For e.g.:

    <fetch version="1.0" output-format="xml-platform" mapping="logical" distinct="true ">

     <entity name="group">

       <attribute name="gropupid" />

     </entity>

    </fetch>

    Hope this helps.

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

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans