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 :
Supply chain | Supply Chain Management, Commerce
Answered

Somehow SSRS report figure not matching with SQL query figure

(2) ShareShare
ReportReport
Posted on by 2,430
Hi Experts,
 
Somehow SSRS report figure not matching with SQL query figure. In SSRS report Active customer is 555 and in SQL is 688.
 
I have run set date range from 1-Mar-2022 to 1-Mar-2023. Please help me I tried even extracting in excel sheet and it is showing exact 688.
 
Below is SQL result:
 
 
 
 
ProcessReport method is below:
  public void processReport()
    {
       
       
        contract = this.parmDataContract() as SFA_RetentionContract;
        TransDate transDate = contract.parmReportDate();
        
        CustTable custTable, custTableNew;
        CustInvoiceJour custInvoiceJour, custInvoiceJourNew;
        CustTrans custTrans;
        CustInvoiceTrans custInvoiceTrans, custInvoiceTransNew;
        CustInvoiceLine custInvoiceLine;
    
        Map customerInvoiceCount = new Map(Types::String, Types::Int64);
        Map customerFirstInvoiceDate = new Map(Types::String, Types::Date);
        integer                    customerCount = 0;
        integer activeCust = 0;
        integer newCondition = 0;
        Set firstPeriodCustomers = new Set(Types::String);
        Set secondPeriodCustomers = new Set(Types::String);


        while select minof(InvoiceDate), InvoiceAccount from custInvoiceJour
group by InvoiceAccount
            where custInvoiceJour.InvoiceDate >= str2Date('3/1/2022',213)
                    && custInvoiceJour.InvoiceDate <= str2Date('3/1/2023',213)
          exists join custTable
            where custTable.AccountNum==custInvoiceJour.InvoiceAccount 
&& 
(custTable.CustGroup != "SCP" 
|| custTable.CustGroup != "RMS" 
|| custTable.CustGroup != "FAS")
               
         exists join custInvoiceTrans
              where custInvoiceTrans.InvoiceId == custInvoiceJour.InvoiceId
                    && 
(custInvoiceTrans.ItemId like '101*' 
|| custInvoiceTrans.ItemId like '201*' 
|| custInvoiceTrans.ItemId like '301*' 
|| custInvoiceTrans.ItemId like '251*')

            {

                customerFirstInvoiceDate.insert(custInvoiceJour.InvoiceAccount, custInvoiceJour.InvoiceDate);

            }



          
        

        

      


        while select InvoiceAccount,count(RecId) from custInvoiceJour 
group by InvoiceAccount
            where custInvoiceJour.InvoiceDate >= str2Date('3/1/2022',213)
                    && custInvoiceJour.InvoiceDate <= str2Date('3/1/2023',213)
          exists join custTable
            where custTable.AccountNum==custInvoiceJour.InvoiceAccount 
&& (custTable.CustGroup != "SCP" 
|| custTable.CustGroup != "RMS" 
|| custTable.CustGroup != "FAS")
               
                exists join custInvoiceTrans
                where custInvoiceTrans.InvoiceId == custInvoiceJour.InvoiceId
                    && (custInvoiceTrans.ItemId like '101*' 
|| custInvoiceTrans.ItemId like '201*' 
|| custInvoiceTrans.ItemId like '301*' 
|| custInvoiceTrans.ItemId like '251*')
        {

            customerInvoiceCount.insert(custInvoiceJour.InvoiceAccount,custInvoiceJour.RecId);

        }

        MapEnumerator mapEnumerator = customerInvoiceCount.getEnumerator();

        while (mapEnumerator.moveNext())
        {
            str accountNum = mapEnumerator.currentKey();
            Integer invoiceCount = mapEnumerator.currentValue();
            TransDate firstInvoiceDate = customerFirstInvoiceDate.lookup(accountNum);

            if(firstInvoiceDate != dateNull())

            {
                Integer numberOfMonths = (year(oneYear) - year(firstInvoiceDate)) * 12 
+ (mthOfYr(oneYear) - mthOfYr(firstInvoiceDate)) ; 
                real invoiceRatio = (invoiceCount / numberOfMonths);

                if (invoiceRatio >= 0.5)
                {
                    firstPeriodCustomers.add(accountNum);
                }
            }
        }

        activeCust = firstPeriodCustomers.elements();
        tmpTable.ActiveCustomer = activeCust;
    
        tmpTable.insert();
}
 
 
and in SSRS report output is below:
 
 
Thanks,
Faiz
  • Verified answer
    faiz7049 Profile Picture
    2,430 on at
    Thanks to all, Problem was in SQL query JOIN. After using EXISTS number of SSRS report and SQL result matching.
     
    Thanks again,
    Faiz
     
     

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders

These are the community rock stars!

Leaderboard > Supply chain | Supply Chain Management, Commerce

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 100 Super User 2026 Season 2

#2
Aayush Tiwari Profile Picture

Aayush Tiwari 71

#3
Paolo Cecchelli Profile Picture

Paolo Cecchelli 69 Super User 2026 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans