I have a report showing a table showing details, it has about 380 rows.
I want to add a simple bar chart using the same dataset.
In the chart is one value and one group: value = sum(amount) and category group = description order by sum(amount).
This is working fine, but chart is showing about 120 bars, because of 120 distinct descriptions. I only want to display the top n.
Can this be done in reporting services itself or do I need to do this is a query?
I found the answer myself.
There is a filter operator 'Top N' which can be used. It seems the field used in expression doesn't matter.
However it seems Reporting services first performs the topN en than sort the remaining data. So I had to make a second dataset anyway.
Related
I saw the post on WHERE clause in SSRS expression. I am also trying to do a where clause, but in a different way. I need to show ItemDesc when ItemId = 4. I set a parameter so that it will always equal 4 for this cell. Now I just need the matching description field. I cannot hard code it because the description may change one day. Is there a way to associate the two fields?
=IIF(Parameters!ItemID_4.Value = 4, Fields!ItemDesc.Value,"")
I am converting from Crystal Reports to SSRS. This first image is the output from CR. I only need to show that ItemDesc in that top left cell.
This next image is from SSRS. It is not limiting the descriptions. It seems to be doing what my expression is saying. ItemID = 4, so display all ItemDesc values but the two fields are not associated right now. I need it to only show the matching value.
Thank you for your help.
I cannot hard code it because the description may change one day.
You are hard coding the parameter anyway by trying to do it that way. I don't think you need a parameter to achieve the result unless you are restricted from adjusting the dataset query.
If you are using an embedded SQL query for your dataset, I would just put a filter in WHERE clause: WHERE ItemID = 4
Another way if you can't adjust the query is to go to Report Data view > Right click on the dataset for your table, "Dataset Properties" > go to the "Filters" tab and add a filter with these settings: Expression = ItemID, Operator = "=", Value = "4" (or "#ItemID" if you want to keep your parameter).
I'm stuck on an issue where I want my bar chart to grow vertically based on the number of groups display in my graph.
I have a shared dataset looking at a SharePoint list then I have a dataset
in my report referencing this but applying some filters based on date ranges. I've then set that as the dataset for my graph which works neatly but there's a widely varying number of potential grouping categories to be displayed. I was looking at this article here which is a neat way to do it, but I don't want a manually set parameter, I just want it to grow based on whatever shows up. One thought I had was in the DynamicHeight expression was to check the number of "CategoryGroups" that show up but I can't see a way of getting to the chart object in the VB expression editor.
I saw an example of doing group by in SQL in the dataset editor but I don't get that option looking at a SharePoint list. Is there a way in DynamicHeight expression editor to reference report objects?
Similar to the article, you can use a distinct count of the group items in a expression in order to dynamically size your chart.
The expression could look like:
= (2 + CountDistinct(Fields!item.Value, "DataSet1")) & ” cm”
Which is (minimum size + size for each group item) in cm (or any unit you prefer)
I am new to SSRS. I have a report that goes like this
Type Amount
A 500
B 200
A 100
C 400
C 200
I want to convert this to a report like this
Type Total Amount
A 600
B 200
C 600
Basically get distinct Types on the left column and th totals for those types in the right column. Is there a way i can do that easily?
Thanks
Starting with you simple report which just lists the records in your DataSet:
Design:
Results:
Right click on (Details)in the Row Groups section and choose Add Group -> Parent Group:
Choose the field you want to group by (Type in our example) from the Group by: dropdown, choose to add either a group header or footer and click OK:
Your table will now look something like this:
You can delete the second column and the third row - or second row if you chose to add a group footer earlier - entirely (clicking OK when deleting the row and being prompted to delete the associated group), leaving a layout like this:
Now just click the field selector for the empty cell in the table and choose your Amount field:
or right click on the empty cell, choose Expression from the context menu and enter the following expression:
=Sum(Fields!Amount.Value)
either of which should result in the formula being placed into the cell:
Now run your report and you should get the expected result:
There's loads of places online with similar guides and resources which you can also consult:
MSDN Reporting Services Tutorial (Adding Grouping and Totals)
MS TechNet (Calculating Totals and Other Aggregates)
MSDN (Add a Total to a Group or Tablix Data Region)
There are also several other similar questions here on SO which you'll find if you just search for them.
I have a report where users can select items from various location. And I have 3 datasets performing calculations where the third dataset takes the sum where item number is 4942200 and then calculates the values (as shown below):
=SUM(IIf(Fields!masterno.Value= "4942200",Fields!Owned.Value,0))+SUM(IIf(Fields!masterno.Value= "4942200",Fields!Subbed.Value,0))
This is returning error for some reason. The subbed column is toggled based on parameter (visibility). But before I add the toggle functionality, I want to make sure this is working. Can anyone help. I have also tried:
=SUM(IIf(Fields!masterno.Value= "4942200",Fields!Owned.Value+Fields!Subbed.Value,0))
This seems to fail as well. Help would be greatly appreciated.
I would wrap a CDec around Owned, 0 and Subbed, e.g.
=SUM(IIf(Fields!masterno.Value= "4942200",CDec ( Fields!Owned.Value) ,CDec (0 ) ))+SUM(IIf(Fields!masterno.Value= "4942200",CDec (Fields!Subbed.Value ) ,CDec ( 0 )))
If Owned and Subbed are already Decimals, those CDec's may be redundant. On the other hand SSRS doesnt expose this info and they can change at the whim of the data source.
I have a requirement to show percentages in bar chart on a single bar using SSRS. For example, I want to show a employees by Age in a percentage in an SSRS report.
1.How many % employees between age 20 and 30?
2.How many % employees between age 30 and 40?
3.How many % employees between age 40 and 50?
All this on a chart which has only single bar chart in percentage?
Is it possible?
Thanks
Not sure I'm really understanding the question ("a chart which has only single bar chart in percentage"?), and I realise it's an old one, but I just came here with what I think is the same problem, and wanted to offer the solution I've come up with.
As far as I understand it, you have a bar chart which shows employees grouped by age. Age bracket along the X axis, number of employees (which I'll presume is calculated by something like "COUNT(Fields!EmployeeID.value)") up the Y axis. You want to see the percentage of employees which fall into each bracket.
What I've done is go into the chart properties, "Data" and select the "Values" entry for "Employees" (or similar). Then, hit Edit and add point labels, with a data label such as:
=COUNT(Fields!EmployeeID.value) / COUNT(Fields!EmployeeID.value, "Employees")
Where "Employees" is the name of your data set.
This is dividing the value of the current data group (from the "Values" tab) by same value but taken over the whole dataset.
Enter a format code of something like "#0%", et voila!
It achieved what I was after, and I hope it can help others with the same question.
You can easily do it in 2008, but I guess that's not what you wanted to hear.
So basically you want the concept of a pie-chart but as a single bar (known as a linear gauge in 2008)?
I don't think you can. This is about the limit of what you can do
http://msdn.microsoft.com/en-us/library/aa964128%28SQL.90%29.aspx
You could always buy dundas http://www.sql-server-performance.com/articles/reporting/Enhancing_Reporting_Services_with_Dundas_Reporting_Controls_p1.aspx
essentially this what MS have rolled into 2008