Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Dynamics 365 general forum

How to get distinct parameter value in SSRS whose connection source is FetchXML

(0) ShareShare
ReportReport
Posted on by Microsoft Employee
I am quite new to Dynamics365 and I trying to get distinct values in SSRS Parameter drop-down. And I am using fetch XML(Microsoft dynamics 365 fetch) as the data source connection. I have placed the following code for removing duplicates in the report properties.
Public Shared Function RemoveDuplicates(parameter As Parameter) As String()
Dim items As Object() = parameter.Value

System.Array.Sort(items) 

Dim k As Integer = 0

For i As Integer = 0 To items.Length - 1

If i > 0 AndAlso items(i).Equals(items(i - 1)) Then 
Continue For

End If 
items(k) = items(i)

k += 1 
Next

Dim unique As [String]() = New [String](k - 1) {}

System.Array.Copy(items, 0, unique, 0, k)

Return unique 
End Function

Problem is the drop-down is greyed out and not able to choose any values as Parameters. There is not so many resources for Fetch XML.I followed the instruction from this page: https://www.c-sharpcorner.com/article/remove-duplicate-filter-values-from-ssrs-parameter-drop-down/

Need help, struck with this for past 2 days.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to get distinct parameter value in SSRS whose connection source is FetchXML

    Hi Fun,

    Thanks for saving me. It worked. :-)

  • Verified answer
    Alex Fun Wei Jie Profile Picture
    Alex Fun Wei Jie 33,626 on at
    RE: How to get distinct parameter value in SSRS whose connection source is FetchXML

    Hi,

    you can refer below discussion. Besides that, remove the code you written to remove the duplicates value. the only thing is, include one attribute in your fetchxml. 

    community.dynamics.com/.../898831

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How to get distinct parameter value in SSRS whose connection source is FetchXML

    Hi Adrian,

    I have did that as well. But no luck.

    The attribute name of my parameter is fhl_whsubprojectid.

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

     <entity name="msdyn_warehouse">

       <attribute name="msdyn_name" />

       <attribute name="createdon" />

       <attribute name="msdyn_description" />

       <attribute name="msdyn_warehouseid" />

       <attribute name="fhl_whsubprojectid" distinct="true" />

       <order attribute="msdyn_name" descending="false" />

     </entity>

    </fetch>

    The thing is the Parameter label is grayed out.  I have no clue what I am doing wrong.

  • Suggested answer
    Adrian Begovich Profile Picture
    Adrian Begovich 1,019 Super User 2025 Season 1 on at
    RE: How to get distinct parameter value in SSRS whose connection source is FetchXML

    Hi Rama4407,

    Try adding distinct="true" to the FetchXML attribute tag, like this:

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

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,494 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,309 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans