SSRS Matrix Report
Please see below matrix report before and after I run. How can I find percentage of below marked fields,
for example: 1/3=0.33 (%33) Female(PAs)/Total(PAs)=?
Erdal Huzmeli
Hi Erdal,
According to your description, you have a matrix report and you want to get percentage of two different column in this report. Right?
In Reporting Service, we can’t just use ReportItem function or aggregation function with scope string to calculation when we are working in a matrix because the columns of matrix are dynamic. So we need to define some functions in custom code and do calculation
by calling those functions. Your scenario has been tested in our local environment. Here are some steps and screenshots for your reference:
Add the custom code below into your report:
Dim Shared Num1 As Integer
Dim shared Num2 As Integer
Public Function GetPA(PA as Integer, Type as String)
If Type = "Male" Then
Num1=PA
ELSE If Type="Female" Then
Num2=PA
End If
Return PA
End Function
Public Function GetMalePct()
Return Num1/(Num1+Num2)
End Function
Public Function GetFemalePct()
Return Num2/(Num1+Num2)
End Function
Ps: We notice that Total PA=Male PA +Female PA. So we use “Num1+Num2” in the functions that we define in the custom code instead of using “SUM(Fields!PA.Value)” in expression.
Put the expression below into the PA textbox in Gender group:
=Code.getPA(SUM(Fields!PA.Value),Fields!Gender.Value)
Put the expression below Female textbox within Gender Percentage:
=Code.getFemalePct()
Put the expression below Male textbox within Gender Percentage:
=Code.getMalePct()
Save and preview, the matrix and result looks like below:
Reference:
Custom Code and Assembly References in Expressions in Report Designer (SSRS)
How to calculate the Percent change in a dynamic
If you have any question, please feel free to ask.
Best Regards,
Simon Hou
Similar Messages
-
SSRS Matrix report to show or hide year column based on parameter value "Date" selected.
Hey experts!
I have a requirement an ssrs matrix report should display columns (year/s) based on parameter value (date/s).
My Dataset fileds are: Product, Year_name, Month_name, Date
Currently my report output looks like this-
Param Date: 2013-08-01 00:00:0.000
Product +Calender2011 +Calender2012 -Calender 2013........ +Calender2014
Total
Total Jan13 Feb 13 Mar13.. Dec13 Total Total
Abc 100
220
10 20 30....... 20 250 400
Xyz 110
200 50 80 40....... 30 450 600
My requirement: if I'm selecting Date parameter value as '2013-xx-xx' I should only able to see Year column 'Calender2013' and rest of the years should hide. Similarly If I'm selecting Date parameter value as '2014-xx-xx' I should only able to
see Year column 'Calender2014' .
Appreciate your kindly help.
AfanHi Afan,
According to your description, you want to only show the selected year on your report, right?
In this case, you need to get the year from the date parameter using the expression below
=Year(Parameters!Date.Value)
And then use the expression below to get the year from Year_Name field.
=Right(Fields!Year_Name.Value,4)
Then add a filter to the dataset to filter the data like below
Expression:=Year(Parameters!Date.Value)
Operator:=
Value:=Right(Fields!Year_Name.Value,4)
Reference
http://msdn.microsoft.com/en-IN/library/dd255287.aspx
If you have any questions, please feel free to ask.
Regards,
Charlie Liao
TechNet Community Support -
Column limit in SSRS Matrix report being uploaded to Report Manager in SQL2008 R2
Hi,
I am getting this error :
SQL Server Reporting Services
Error
The attempt to connect to the report server failed. Check your connection information and that the report server is a compatible
version.
I am attempting to upload my SSRS Matrix report to Report Manager. The report has a lot of columns (109 row columns followed by the variable number of column columns).
After trial and error, I discovered that when I only have 107 row columns I can upload successfully.
Can anybody explain why this is happening? Is there a limit of 107 columns?
Thanks,
GRusteanAs there was too much nesting in the tablix inside the report. We added new tablix and shifted some rows to that tablix. Because maximum of 36 level nesting is allowed in tablix
-
Please help. I have a matrix report. In the report I have row group PO Type. One the Column groups I have a parent group by Fiscal Year, and then a child group by Month. When I run the report, I get two years of data back broken
out by month. Please see below.
Now here is where I am getting stuck. I need to take the variance between the current month of the current year, from the same month of the prior year. So I need to show the difference between Oct , 2014 from Oct, 2013. November, 2014 from November
2013... etc. etc.
In the example below, how do I create a column or row showing the variance for Contracts for October 2014. I need to take the contracts for October 2014 which is 3 and subtract that from October 2013 which is 8. Any suggestions? How do I do that
for each month? Then I need to do it for the quarter... then the year? But I'll be happy if I can just get the month working first.
Any help will be appreciated.
here is what my rdl file looks like.
Here is what my report looks like when I render it.Hi Adrian_s2012,
According to your description, you want to compare values for the month of current year with the month of prior year and get the variance. Right?
In Reporting Services, we don't have any function to get this "Year to Year" Growth. In this scenario, if you data source is a cube, we suggest you use Analysis Services to achieve your requirement. If this data source is just from database, it will be hardly
to calculate the variance because we need to compare the values within every two different column group and matrix generate adjacent columns one by one. Even we make it by using custom, every time executing the long code when generating result
in a cell will reduce a lot of performance, we really don't suggest to do that in SSRS. Here is a thread with much easier requirement, please take a reference of that:
http://social.msdn.microsoft.com/Forums/office/en-US/842e2dcb-d949-4297-9d91-eac989692cb5/difference-between-the-grouped-column?forum=sqlreportingservices
If you have any question, please feel free to ask.
Best Regards,
Simon Hou -
How to Substract Adjacent Columns in SSRS Matrix Reports
Hello Experts!
Month 2005
2006
January 648343.8132
May 733248.3506
June 587549.2014
July 259933.2074
623172.5646
August 501182.4458 513690.3892
I have a report like this and i want to show the o/p like
Month 2005 2006 2005-2006
January 648343.8132 648343.8132
May 733248.3506 766248.3506
June 587549.2014 587549.2014
July 259933.2074
623172.5646 363239.3572
August 501182.4458 513690.3892 12507.9434
Tried using Previous Function but it is not working for Matrix Reports i.e. Overlapping Columns
Tried Custom Code like
Public Shared previous as Integer
Public Shared current as Integer
Public Shared Function GetCurrent(Item as Integer) as Integer
previous=current
current=Item
return current
End Function
Public Shared Function GetPrevious()
return previous
End Function
I've taken the Column Insert Column-->Insert Group-Right and in that i written the expression as
=Code.GetCurrent(fields!Score.Value) & "-Previous-" & iif(Code.GetPrevious()=0,"",Code.GetPrevious())
Still it is not working
Please help me regarding this
Thanks & Regards
VIJAYHello RSINGH,
Previous Function is not working Matrix Report. So i written the expression like
=SUM(Fields!Sales.Value)-Previous(SUM((Fields!Sales.Value)))
The result is is subtracting Row wise but i want to subtract Column Wise i.e. 2006 Jan-2005 Jan & 2007 Jan-2006 Jan & 2006 Feb-2005 Feb so on...
but with the above expression it is showing 2005 feb-2005 Jan and 2005 Mar-2005 Feb and son on -
Calculate percentage between two rows in a matrix report with a single row group in SSRS 2008
I need your help. I have a matrix report in ssrs 2008. The report contain one field value column and one value column. I need to calculate a percentage for two values. For example : row 1 : Discount 10 Row 2 : Sales 100 Result : 10/100. I have only one
row group, I need to have a condition where Field = Discount % on Revenue then Discount/Total Turnover. Because of the grouping for total, I am not being able to calculate the %, its just totalling the % discount. Kindly refer to the snapshot of the
report.Hi Thanks a lot for your answer, but unfortunately it didn't work,the report is reading from a stored procedure which I have unpivot to convert all columns into rows, so that's why Discount % on Revenue, Discount and Total Turnover is found in one column.
So the Field!Col.Value is the Discount % on Revenue, Discount and Total Turnover. I have tried to change the code to
"=SUM(IIF(Fields!Col.Value = "Discount",Fields!value.Value),0))
/IIF(SUM(IIF(Fields!Col.Value = "Turnover Total",Fields!value.Value),0)) = 0 ,
Nothing,SUM(IIF(Fields!Col.Value = "Turnover Total",Fields!value.Value),0)))" but to no avail. Any other suggestion will be most welcome.
Thanks.
If everything you're getting from stored procedure then you need to calculate and bring the value from there itself.
Please Mark This As Answer if it solved your issue
Please Mark This As Helpful if it helps to solve your issue
Visakh
My MSDN Page
My Personal Blog
My Facebook Page -
SSRS 2005 - Dynamically control the width of columns in Matrix report or Hide any column
Hi All,
I just want to hide some column without having white space in Matrix report in SSRS 2005. Although I am aware of that perhaps this feature is not available on SSRS 2005. So, I just want to know if we can handle the width of column dynamically(using expressions)
in matrix report?
Please help. Thanks in Advance.
Regards
KumudHi Kumud,
Based on my test, SSRS is not support column dynamically width. It has property “CanGrow” of text box. If we configure the property to True, it will wraps to next line if needed. In SSRS 2008, we can hide some columns without white space. If possible, I
recommend you update your SSRS 2005 to SSRS 2008.
There is a similar issue, you can refer to it.
http://social.msdn.microsoft.com/Forums/sqlserver/en-US/9e6043f1-c458-4540-be59-d37b02feab8a/dynamic-column-width-for-a-report?forum=sqlreportingservices
Alternatively, I recommend you that submit a wish to the Microsoft Connect at
https://connect.microsoft.com/SQLServer/Feedback. Your feedback is valuable for us to improve our products and increase the level of service provided.
Regards,
Alisa Tang
Alisa Tang
TechNet Community Support -
Hello, Expert,
Could you please help me with the following problem? Thanks in advance!
I have designed the matrix report (SSRS 2012) with database table structure looks like below.
Week
Version
Count
Week1
V1.1
4000
Week1
V1.2
4000
Week1
V1.3
4000
Week2
V1.1
3000
Week2
V1.2
3000
Week2
V1.3
3000
Week3
V1.1
2000
Week3
V1.2
2000
Week3
V1.3
2000
Week4
V1.1
1000
Week4
V1.2
1000
Week4
V1.3
1000
The matrix report displays like below. Column grows based on no of Week in the table.
Week1
Week2
Week3
Week4
V1.1
4000
3000
2000
1000
V1.2
4000
3000
2000
1000
V1.3
4000
3000
2000
1000
What I want to do now is: instead of the Count values, I need to calculate the percentage of each week over the
Count in Week1 so that each cell displays Count(Week2)/Count(Week1), Count(Week3)/Count(Week1), etc. What is the SSRS expression for that? I’m new to SSRS, Please help!Heidi,
Thank you so much for your reply and solution! Now I know how to get the first field in a group. But I can't apply your solution directly just yet because in order to explain my problem I simplified my data structure. My real data structure has a nested
group like this:
Week VersionMajor VersionMinor Count
Week1 V1 V1.1 2000
Week2 V1 V1.1 1500
Week3 V1 V1.1 800
Week1 V1 V1.2 1000
Week2 V1 V1.2 500
Week3 V1 V1.2 200
Week1 V1 V1.1 2000
Week2 V1 V1.1 1500
Week3 V1 V1.1 800
Week1 V1 V1.2 1000
Week2 V1 V1.2 500
Week3 V1 V1.2 200
Here is the query for the above data:
SELECT 'Week1' AS Week, 'V1' AS VersionMajor, 'V1.1' AS VersionMinor, 2000 AS Count
UNION ALL
SELECT 'Week2' AS Week, 'V1' AS VersionMajor, 'V1.1' AS VersionMinor, 1500 AS Count
UNION ALL
SELECT 'Week3' AS Week, 'V1' AS VersionMajor, 'V1.1' AS VersionMinor, 800 AS Count
UNION ALL
SELECT 'Week1' AS Week, 'V1' AS VersionMajor, 'V1.2' AS VersionMinor, 1000 AS Count
UNION ALL
SELECT 'Week2' AS Week, 'V1' AS VersionMajor, 'V1.2' AS VersionMinor, 500 AS Count
UNION ALL
SELECT 'Week3' AS Week, 'V1' AS VersionMajor, 'V1.2' AS VersionMinor, 200 AS Count
UNION ALL
SELECT 'Week1' AS Week, 'V1' AS VersionMajor, 'V1.1' AS VersionMinor, 2000 AS Count
UNION ALL
SELECT 'Week2' AS Week, 'V1' AS VersionMajor, 'V1.1' AS VersionMinor, 1500 AS Count
UNION ALL
SELECT 'Week3' AS Week, 'V1' AS VersionMajor, 'V1.1' AS VersionMinor, 800 AS Count
UNION ALL
SELECT 'Week1' AS Week, 'V1' AS VersionMajor, 'V1.2' AS VersionMinor, 1000 AS Count
UNION ALL
SELECT 'Week2' AS Week, 'V1' AS VersionMajor, 'V1.2' AS VersionMinor, 500 AS Count
UNION ALL
SELECT 'Week3' AS Week, 'V1' AS VersionMajor, 'V1.2' AS VersionMinor, 200 AS Count
And my matrix table looks like this:
What I need to do is to calculate the percentage of each week over week1 for
1) V1 Total
2) V1.1
3) V1.2
I can't use your solution directly because I need to apply Sum function for each cell and the Sum function gives me error when I try to use it on the denominator
First(Fields!Count.Value,"VersionMinor"). If you could help me further to get to the final solution, I'd really appreciate it!!
Happy New Year! -
How to calculate difference and percentage in matrix report dynamic columns in SSRS 2008
Hi Friends,
I need to calculate Difference and Percentage In matrix report SSRS 2008
1) Row grouping based On Product
2) Column Grouping Week and Fiscal Year Current week and Previous Year same Weeks
3)Data Invnetory(Value fileld)
Example:
If value1 and Value2 Available we need to calculate Percentage and Difference.Otherwise Not required NA I need to Show.
For example If Particular week,Current year data is available,Previous year week data is not available No
need to cal Diff and Percentage we need to show Empty.
Below Code is working for If two values is available.
If any one of the fiscal year week data is not there it's taking some garbage values.
I tries with If condition in GetPCT() and GetDiff() It's not working.
Can some one please help me on this.
I am using the custom code
Public Shared Value1 as String
Public Shared Value2 as String
Public Shared previous as string
Public Shared previousweek as string
Public Shared Function GetValue(Value as String,partner as String,Week as String) as String
If partner =previous and Week =previousweek Then
Value2=Value
Else
previous=partner
previousweek=Week
Value1=Value
End If
return Value
End Function
Public Shared Function GetDiff()
return Value2-Value1
End Function
Public Shared Function GetPct()
return (Value2-Value1)/Value1
End Function
How to handle this.
Thank You, Manasa.VHi veerapaneni,
According to your description, if one of the fiscal year week doesn’t have data, the custom code returns false results.
For your requirement, if NULL value exists in the database, we should replace it as zero then perform calculate. So within the code, we should judge whether the value is NULL. To achieve your goal, please refer to the steps below:
1. Create a table like below.
create table dif4
([Product Group] varchar(50),
[Week] varchar(50),
[Fiscalyearweek] varchar(50),
value int
insert into dif4 values
('Desktops','W01','FY14W01',0),
('Desktops','W01','FY15W01',45),
('Desktops','W02','FY14W02',null),
('Desktops','W02','FY15W02',30),
('Desktops','W03','FY14W03',12),
('Desktops','W03','FY15W03',50),
('Notebooks','W01','FY14W01',35),
('Notebooks','W01','FY15W01',56),
('Notebooks','W02','FY14W02',45),
('Notebooks','W02','FY15W02',87),
('Notebooks','W03','FY14W03',75),
('Notebooks','W03','FY15W03',105),
('Tablets','W01','FY14W01',34),
('Tablets','W01','FY15W01',46),
('Tablets','W02','FY14W02',49),
('Tablets','W02','FY15W02',96),
('Tablets','W03','FY14W03',42),
('Tablets','W03','FY15W03',113)
2. Add the custom code in the Report Properties.
Public Shared Value1 as Integer
Public Shared Value2 as Integer
Public Shared previous as string
Public Shared previousweek as string
Public Shared Function GetValue(Value as Integer,product as String,Week as String) as Integer
If Value=Nothing Then
Value=0
End If
If product =previous and Week =previousweek Then
Value2=Value
Else
previous=product
previousweek=Week
Value1=Value
End If
return Value
End Function
Public Shared Function GetPct()
If Value1=0 Then
return 0
Else
return (Value2-Value1)/Value1
End If
End Function
Public Shared Function GetDiff()
return Value2-Value1
End Function
3. Design the matrix like below.
4. Then get the expected results.<o:p></o:p>
If you have any question, please feel free to ask.
Best regards,
Qiuyun Yu
Qiuyun Yu
TechNet Community Support -
Center a report title in Matrix report SSRS 2008
I have fought with my first Matrix report for about a week now. What a pain. Now of course when I seem to be close to the end I can't center my report title on the report. How do I center a title? Help please. Thanks. SSRS 2008.
Hi gainesvillepratt,
After testing the issue in my local environment, we should add a textbox with title value above the matrix. Changing the Width of textbox with the same size as the rendered the matrix Width (Row Groups area width + Column Groups area width * the number of
columns in column group), then setting the TextAlign property to Center in the Properties Windows pane. Thus we can achieve your requirement.
If there are any other questions, please feel free to ask.
Thanks,
Katherine Xiong
Katherine Xiong
TechNet Community Support -
Weird SSRS Format Date Output in Matrix report Header
For one of my Matrix reports, the column headers are Dates which I am trying to format in the form of 'Mon 07' i.e. short date name followed by date value.
For this I am using the expression - =Format(CDate(Fields!WorkedOnDate.Value),"ddd") I then wanted to trim the right 3 letters.
I am getting weird output. Here is what I am getting for one week- Tue, We2, T12u,ri,SaA,Sun,7on
Any idea what is going wrong? This was asked in this link but that answer didn't help - The
date formats do not seem to work in SSRS
Regards,
Karthik
Please remember to click Mark as Answer and Vote as Helpful on posts that help you. This can be beneficial to other community members reading the thread.Hey Visakh, I realize my mistake now. I was adding the expression as part of Number-> Format property of text box instead of directly on the text box property. Thank you.
Regards,
Karthik
Please remember to click Mark as Answer and Vote as Helpful on posts that help you. This can be beneficial to other community members reading the thread. -
How to calculate percentage and difference of two values in matrix report in ssrs 2008
Hi everyone,
DB--SQL server
SSRS-2008
I am creating matrix report with grouping on WEEK and Fiscalyearweek,
I need to calculate of difference between FY14W01,FY15W01 ande percentage of those..
how to calculate in ssrs level.
Thank You, Manasa.VHi veerapaneni,
According to your description, you want to calculated the increment percentage and difference between two fiscal year week within each week. Right?
In this scenario, since we need to do calculation based on values between dynamically generated cells, we can't simply use expression to achieve this goal. In this scenario, we need to use custom code to record the value for fiscal 14 and fiscal 15, then
we can calculate the difference and percentage within the column group. We have tested your case in our local environment, please refer to the steps and screenshots below:
1. Add the custom code below into the report (you may need to modify the data type based on your scenario:
Public Shared Value1 as Integer
Public Shared Value2 as Integer
Public Shared previous as string
Public Shared previousweek as string
Public Shared Function GetValue(Value as Integer,product as String,Week as String) as Integer
If product =previous and Week =previousweek Then
Value2=Value
Else
previous=product
previousweek=Week
Value1=Value
End If
return Value
End Function
Public Shared Function GetPct()
return (Value2-Value1)/Value1
End Function
Public Shared Function GetDiff()
return Value2-Value1
End Function
2. Design the matrix like below:
3. The result look like below:
If you have any question, please feel free to ask.
Best Regards,
Simon Hou -
SSRS matrix click on the count like a pivot table to get details
Hi,
I am trying to create a matrix report to work similar to a pivot table, where when a user clicks on the count, the details are displayed. When I add the action to open a sub-report, how do I pass in the parameter values for the group that was selected? meaning
if in row group- I have company name, and column group I have job title, when the count gets clicked, i need to pass in the company name for the row that was clicked along with the column group. How can I proceed?
Thanks in advance!Hi NewCSharpUser,
According to your description, you have created a main report which contains company name as row group and job title as column group. And a drill through report which contains company name as a parameter to filter the data. When you click the data region
in the main report, you want to display corresponding details in the drill through report filtered by the company name, right?
In your scenario, you could add a “Go to report” action, then specify a parameter to filter the drill through report. Please refer to steps below:
1. Design the main report like below:
2. Preview the report.
Reference:
Drillthrough Reports (Report Builder and SSRS)
If the method couldn't meet your requirement, please share you report design and expected results for our analysis.
If you have any question, please feel free to ask.
Best regards,
Qiuyun Yu
Qiuyun Yu
TechNet Community Support -
Find the difference between two columns in an ssrs matrix ? MSCRM
Hi All,
I am working in reporting part of our project (On-line MSCRM 2013) & in reporting services.
I am trying to create report using fetch xml based. Below is the snap what we required the result.
Kindly help me, how to get the difference in both column. (Its a matrix table where year is grouped).
We need difference between both year Like (Plan Revenue of 2013 & Plan Revenue of 2014 difference in Plan Revenue Diff section) and same for Actual
Revenue.
https://social.microsoft.com/Forums/en-US/054d5ca4-0d38-4dc6-84a8-88866cc228fe/find-the-difference-between-two-columns-in-an-ssrs-matrix-mscrm?forum=crmdevelopment
Thanks,
Mohammad ShariqueHi Bro,
I used parametrized option for year and done the report,Currently we are getting values in Difference column now i want to show
that value in percentage. How can we show the percentage based on that value. Means i want to show the Difference in Percentage.
Kindly help me i tried but getting some issue. Below i am mentioning the code and snap with result.
Below expression using to showing Plan Revenue in Percentage for year.
=
Sum(IIF(Fields!new_year.Value =Parameters!StartYear.Value,cdec(Fields!new_planrevenueValue.Value/1000), cdec(0)))
- Sum(IIF(Fields!new_year.Value =Parameters!EndYear.Value,cdec(Fields!new_planrevenueValue.Value/1000), cdec(0)))
/IIF(Sum(IIF(Fields!new_year.Value = Parameters!StartYear.Value,cdec(Fields!new_planrevenueValue.Value/1000), cdec(0)))>0,
(Sum(IIF(Fields!new_year.Value = Parameters!StartYear.Value,cdec(Fields!new_planrevenueValue.Value/1000), cdec(0))))
,1)
)*100))
Result issue is as below in snap with highlighted in red colour.
Kindly help me on this issue also :) -
Row column group hiding in matrix report
Hi ,
I need to hide the repeated rows in matrix report,in below with red rounded (4%,4%) is coming twice for single resource.
I need to show only one 4% for this resource.How to do this in matric report.
thanks
bhupesh.rthose rows are not duplicates as far as SSRS is concerned as date values for them are different. So you need to change the logic at your backend query to return one out of these two records. Logic you alone can come up with as we dont know your business
rules, neither your tables and you've not posted anything barring a report screenshot.
Alternatively, if you want our help on this post your backend tables with some sample data and explain your rules for getting the required output.
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs
Maybe you are looking for
-
Require a BAPI which will do VL02N posting,PGI and create an Invoice
Hi Gurus, My Requirement: I will be getting an excel file from the legacy system which will provide me with the Delivery numbers whose Shipment has been confirmed. I need a BAPI which will post the picking in VL02N for those Deliveries and do the PGI
-
My iphone was restored and i tried to back it up, but instead of getting all of my information i got my mother's instead. I dont know if i should try to reset my phone again because im worried that my mother will lose all of her data too??
-
Data loading - Member containing comma taken in point-of-view
Hi, I tried loading date into planning. My point-of-View contains a member which has comma in it. When loading it is considering that member as two different members. Has anyone tried loading data into planning with members having comma. Eg. Item No.
-
Factory boxed Apple usb cable wont fit in 4S
Hi, I recently purchased an iPhone 4S while overseas. In the box it came with ear phones, usb wall charger and a usb cable. The end of the usb cable that is supposed to fit into the iphone won't fit in. On closer inspection I found that one of the tw
-
Passing ICM peripheral variables from Agent to IVR
Hello, I need to know if this is possible since i can't manage to make it work. The call-flow is : VG->CVP->ICM->Agent While the call is in the ICM script , i saved the ICM peripheral variable 4 as the language the customer chooses at the beginning o