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 :
Service | Customer Service, Contact Center, Fie...
Answered

Help with a rollup query

(0) ShareShare
ReportReport
Posted on by 5

Hello - I'm hoping to get some assistance with a roll up query please. Obviously, a contact record can have multiple opportunities but I need to get a list of contact records which only have linked lost or open opportunities therefore if there is a linked won opportunity, I don't want to see the contact record. Is there a way I can exclude these type of contact records? Below is the logic I am currently using in the roll up query entity which isn't working as hoped as it is still returning contact records which have both a lost and won opportunity. 

Entity: Lead

Opportunity(Contact) Contains Data

Status = Open / Lost

Many thanks, 

I have the same question (0)
  • Community Member Profile Picture
    on at

    Hi Nosilla17,

    Does the ‘rollup query’ you mentioned above refer to the one shown on the screenshot below?

    pastedimage1618292300762v1.png

    Also, you mentioned that you want to list contacts records, why you use lead entity in the query?which one entity is your need?

    pastedimage1618292434747v2.png

    Anyway, now suppose you want to list all contact records that opportunity status is Open or Lost.

    Contact and Opportunity entity is 1:N relationship, but it doesn’t means that they just have only one relationship, if so, you need add all related opportunities as filter in the query.

    1.Go Settings > Customizations > Customize the system> Contact > 1:N relationships to check relationship between contact and opportunity .

    pastedimage1618293464166v3.png

    2.Add filter in the rollup query.

    From the previous step, there are three 1:N relationships between Contact and Opportunity, so you need add these three all in the query, just like following screenshot:

    Not set Status = Open / Lost, because opportunity status just have three value(Open/Lost/Won), set ‘Status does not equal Won’ directly can be more concise.

    pastedimage1618293628393v4.png

    Now, you can check that it still returning contact records which have a won opportunity or not.

    Regards,

    Leah Ju

    Please mark as verified if the answer is helpful. Welcome to join hot discussions in Dynamics 365 Forums.

  • Nosilla17 Profile Picture
    5 on at

    Hello, Thank you for your reply.

    Apologies, I was referring to contact not lead.

    For the contact, I have 3 x 1:N relationships - I have added these 3 to my query and set the filter to Status does not equal WON but it's still returning a contact record which has 2 opportunities - 1 lost and 1 won. In this scenario, I'm trying to filter out any contact out which has a won opportunity on, regardless of if it has a lost etc. So I only want to see contacts which don't contain any won opportunities

    Thank you

  • Verified answer
    Community Member Profile Picture
    on at

    Hi Nosilla17,

    As long as the contact that has a child with won status, it should not be returned, which is what you need, right?

    In fact, the logic of the rollup query is contrary to your needs, its built-in logic is to return this parent record as soon as one of the child records matches the condition

    For example:

    Contact1 : won opportunity1 and lost opportunity2

    Contact2 : won opportunity3

    Contact3 : lost opportunity4

    Then I query contacts with previous criteria, only contact2 can’t be returned, contact1 and contact3 both have one opportunity meet the condition.

    So rollup query can’t directly return contacts which don't contain any won opportunities.

    Or you can get results you need with Indirect method (For testing purposes, only one relationship is used):

    1.Get all contacts that have opportunities.

    pastedimage1618369905173v1.png

    2.Get all contacts which contain Won opportunities.

    pastedimage1618370231312v2.png

    3.Compare the two results,  contacts that does not appear in the second result are contacts that meets your requirements.

    Regards,

    Leah Ju

    Please mark as verified if the answer is helpful. Welcome to join hot discussions in Dynamics 365 Forums

  • Nosilla17 Profile Picture
    5 on at

    Hello - thank you very much for your reply - that does answer my question.

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!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Service | Customer Service, Contact Center, Field Service, Guides

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 22 Super User 2026 Season 1

#1
Suriyanarayanan V Profile Picture

Suriyanarayanan V 22

#3
Eugen Podkorytov Profile Picture

Eugen Podkorytov 14

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans