Calculation in SSRS don't match SQL Server query

Anonymous
2022-08-08T20:26:29.6+00:00

I have a SQL query that works perfectly but does not match the numbers when i put the query in SSRS. SQL View How can I get the numbers to show up right in my SSRS report to reflect the same numbers in my SQL Query View?

229256-sqlview.png

This is the view in my query:
The view in SSRS
229219-ssrsview.png

As you can see the numbers dont match.

My origional data set query is.

Select  
'11-30' as strAgeing,  
SUM(mnyRent0to30) 'A/R Rent',  
Sum(mnyFees0to30) 'A/R Fees',  
SUM(mnyRent0to30) + Sum(mnyFees0to30)  'Total A/R',  
Sum(mnyRent0to30) / CAST(Sum(mnyOccupiedRent) as float) * 100 as 'Percent A/R',  
1 as intOrder  
FROM tblUBMReport  
LEFT JOIN tblUBMInsuranceShare  
on tblUBMInsuranceShare.intProp = tblUBMReport.intProp  
  
Where tblUBMReport.intProp IN (@Props)   
 and dtReport = @ReportDate   
  
UNION  
  
SELECT  
  
'31-60' as strAgeing,  
SUM(mnyRent31to60) 'A/R Rent',  
Sum(mnyFees31to60) 'A/R Fees',  
Sum(mnyRent31to60) + Sum(mnyFees31to60)  'Total A/R',  
Sum(mnyRent31to60) / CAST(Sum(mnyOccupiedRent) as float) * 100 as 'Percent A/R',  
2 as intOrder  
FROM tblUBMReport  
LEFT JOIN tblUBMInsuranceShare  
on tblUBMInsuranceShare.intProp = tblUBMReport.intProp  
  
Where tblUBMReport.intProp IN (@Props)   
 and dtReport = @ReportDate   
  
UNION  
  
  SELECT  
'61-90' as strAgeing,  
SUM(mnyRent61to90) 'A/R Rent',  
Sum(mnyFees61to90) 'A/R Fees',  
Sum(mnyRent61to90) + Sum(mnyFees61to90) 'Total A/R',  
Sum(mnyRent61to90) / CAST(Sum(mnyOccupiedRent) as float) * 100 as 'Percent A/R',  
3 as intOrder  
FROM tblUBMReport  
LEFT JOIN tblUBMInsuranceShare  
on tblUBMInsuranceShare.intProp = tblUBMReport.intProp  
  
Where tblUBMReport.intProp IN (@Props)   
 and dtReport = @ReportDate  
  
UNION  
  
  SELECT  
'Over 90' as strAgeing,  
SUM(mnyRent90Plus) 'A/R Rent',  
Sum(mnyFees90Plus) 'A/R Fees',  
Sum (mnyRent90Plus) + Sum(mnyFees90Plus) 'Total A/R',  
Sum(mnyRent90Plus) / CAST(Sum(mnyOccupiedRent) as float) * 100 as 'Percent A/R',  
4 as intOrder  
FROM tblUBMReport  
LEFT JOIN tblUBMInsuranceShare  
on tblUBMInsuranceShare.intProp = tblUBMReport.intProp  
  
Where tblUBMReport.intProp IN (@Props)   
 and dtReport = @ReportDate  
ORDER BY intOrder  


  
  
  
SQL Server Reporting Services
SQL Server Reporting Services
A SQL Server technology that supports the creation, management, and delivery of both traditional, paper-oriented reports and interactive, web-based reports.
3,063 questions
Developer technologies | Transact-SQL
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. Jingyang Li 5,896 Reputation points Volunteer Moderator
    2022-08-08T20:57:13.887+00:00

    Remove *100 from your view parts ... * 100 as 'Percent A/R'.

    0 comments No comments

  2. Erland Sommarskog 121.8K Reputation points MVP Volunteer Moderator
    2022-08-08T21:00:27.37+00:00

    As far as I can tell the numbers are the same, save for the percentage column. Now, before I go on, I need to give a warning: I don't know anything about SSRS.

    However, the behaviour appears reminiscent for Excel. You multiply the values with 100 in your query to get percentages. But when you specify the column as per cent in SSRS, SSRS assumes that you are sending decimal fractions. Thus, you should remove the multiplication with 100 in your SQL query.

    A completely unrelated tip: Most of the time you use UNION, you actually want UNION ALL. UNION will strip out duplicate rows which sometimes can bite you. So always use UNION ALL, unless you know that you want distinct values.

    0 comments No comments

  3. Joyzhao-MSFT 15,636 Reputation points
    2022-08-09T03:02:16.423+00:00

    Hi @Jannette Jones ,
    You could set number and data formatting in the Text Box Properties of the report, as shown below:

    229384-image.png

    Preview:

    229356-image.png

    Best Regards,
    Joy


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  4. Anonymous
    2022-08-09T15:26:25.867+00:00

    How would I get % sign in there as well


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.