Skip to main content

Notifications

Announcements

No record found.

Supply chain | Supply Chain Management, Commerce
Answered

Somehow SSRS report figure not matching with SQL query figure

(1) ShareShare
ReportReport
Posted on by 1,883
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
    faiz7049 1,883 on at
    Somehow SSRS report figure not matching with SQL query figure
    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

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 Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,503 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans