Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Unanswered

How to combine two different Count record as one statement or output

Posted on by 1,869

Hello,

I have below code which get  number of records with related owner name. Its working without any issue. But I need owner name not to be repeat and count related number of records in leads and opportunities.

My expected output:

Owner Name        No.of Leads    No.of Opportunities

ABC                           2                      5

BAC                           4                     6

My code.

static void countalluser(Args _args)
{
    smmLeadTable leadTable;
    smmOpportunityTable ssmmOpportunityTable;
    
        while select  count(OpportunityId) from ssmmOpportunityTable group by ssmmOpportunityTable.OwnerWorker
       
    {
        Info(strFmt("Number of Records opportu %1 with oppor Owner %2",
              ssmmOpportunityTable.OpportunityId,
              ssmmOpportunityTable.ownerName()
             
                    )
                );  
    }
        
        while select  count(LeadId) from leadTable group by leadTable.OwnerWorker
    {
         Info(strFmt("Number of Records Lead %1 with lead owner %2",
              leadTable.LeadId,
              leadTable.ownerName()
                    )
                );    
                 
    }
    
    }

  • YY Lim Profile Picture
    YY Lim 960 on at
    RE: How to combine two different Count record as one statement or output

    Not sure what is your output format, is it in table with 3 fields as above, what you could potentially do is create a new table with these 3 fields with Onwer as the primary key and insert/update with the lead and opportunity qty.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans