Adding Calculations to Matrix total

Ted Best 21 Reputation points
2021-06-04T00:06:12.42+00:00

102251-image.png102233-image.png

This is killing me. Any help on this would be greatly appreciated. How would I add some calculated fields to a group in a Matrix? For example I would like to add Yield Ratio which would be the # Binds/# Submissions. Hit ratio would be # Binds /# Quotes

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,061 questions
0 comments No comments
{count} votes

Accepted answer
  1. Joyzhao-MSFT 15,631 Reputation points
    2021-06-04T04:39:39.123+00:00

    Hi @Ted Best ,
    I tested it locally. I think the method worth trying is to use TSQL to complete the calculation.
    Here are the steps :
    1.I created a Tablix named T1 in SSMS. As shown in your image.

    2.Execute the following statement when creating the Dataset:

    select * from T1  
    union  
    select a.YearMonth,'Yield Ratio' Type,cast(a.Count as float)/cast(b.count as float) count,5  
    from (select * from T1  
    where Type='Binds') a  
    inner join (select * from T1  
    where Type='Submission') b  
    on a.YearMonth=b.YearMonth  
    union  
    select a.YearMonth,'Hit ratio' Type,cast(a.Count as float)/cast(b.count as float) count,6  
    from (select * from T1  
    where Type='Binds') a  
    inner join (select * from T1  
    where Type='Quoted') b  
    on a.YearMonth=b.YearMonth  
    

    102279-04.jpg

    3.Create a matrix and sort by "SortOrder", as shown in the figure below:
    Design:
    102322-02.jpg
    Preview:
    102323-03.jpg
    Best Regards,
    Joy


    If the answer is helpful, please click "Accept Answer" and upvote it.
    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.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Ted Best 21 Reputation points
    2021-06-14T15:38:38.08+00:00

    Thank you so much Joy! That was very helpful!

    I was wondering if you could help me with one other thing

    The yellow highlighted field (Average TWP) is a calculated field using values in the New Business, Renewals & Total WP group. I tried the following calculated field but it doesn't work. I'm assuming because I'm looking for a value in a different group. Is there a way to pull that value from a different group?

    Also is there a way to add a blank line in between one more more of the groups but not all in a Matrix? (Green arrow)

    =Switch(Fields!Section.Value = "New Business",VAL(REPLACE(Sum(IIF(Fields!Type.Value = "Declines/Not Quoted", Fields!Value.Value, 0))/Sum(IIF(Fields!Type.Value = "Submission", Fields!Value.Value, 0)),"NaN",0)),  
        Fields!Section.Value = "Renewals",VAL(REPLACE(Sum(IIF(Fields!Type.Value = "Renewals Declined", Fields!Value.Value, 0))/Sum(IIF(Fields!Type.Value = "Renewals Expiring", Fields!Value.Value, 0)),"NaN",0)),  
        ***Fields!Section.Value = "Total WP",Sum(IIF(Fields!Type.Value = "CY TWP", Fields!Value.Value, 0))/(Sum(IIF(Fields!Type.Value = "Binds", Fields!Value.Value, 0))+Sum(IIF(Fields!Type.Value = "Renewals Bound", Fields!Value.Value, 0)))***)  
    

    105453-image.png

    0 comments No comments

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.