This is probably an easy one for a guru here.
I have a datatable of employee results by month structured into the following fields:
Name,Metric,Jan,Feb,Mar,Apr, ...,Dec
When I take this dataset as is, and select it all as an input for a simple column graph in MS Excel, the chart figures out that each series is defined by Name+Metric, the (y-axis) is the defined by the values in Jan-Dec columns, and the columns of the graph are split by date (x-axis).
When I feed this same dataset into MS Access with a simple Select query:
Select Name, Metric, Jan, Feb, Mar... Dec from Results
I need to be able to tell the chart how to use the data. How do I do this?
Also, I know that I could flatten the dataset so the dates are in rows, and then use a Crosstab query for Access to figure it out, but it seems inefficient to condense the data so that Access can just expand it out again. I'm going to assume there is a way to tell the chart somehow how to use the data, which is what I am looking for in an answer here.
Option 1
This is a quick and dirty fix.
Excel essentially is creating 'grouped' categories of Name + Metric via concatenation. A quick and dirty solution is to use the default bar chart and set its Row Source property to:
Select Name & ' ' & Metric, Jan, Feb, Mar... Dec from Results
After that if it still needs adjustment, double click on the chart object from design view and see what chart properties you can mess around with.
Option 2
For more advanced control of the chart layout, select your table Results and mess around with the PivotChart function in Access. This chart can later be added as a subform on another report or form.
side note: you should try to avoid the field name "Name" since it is a reserved word
Related
I'm using MS Report Builder v3.0 to create a report. As part of this report, I have a multi-valued parameter (named #Diagnoses). The labels and some of the values (truncated by the size of the display boxes) of this parameter are shown below:
What I would like to be able to do is display the labels / values the user chooses in a 2-column tablix (I've tried using separate textboxes for the labels / values but the results are mis-aligned).
However, this does not appear to be straightforward. The closest method I've found is this one, which stores the user's choices in an internal parameter in xml format, then queries this parameter to produce a dataset from the xml.
So, I created the xml-producing internal parameter like this:
...and I've created a dataset based on this data, with the following query:
But now when I put these values into a tablix, the labels and values are now on separate rows, like this:
Does anyone have a straightforward way of sorting this out?
Best Wishes
C J
OK - I've solved it (it's not pretty, but it works!)
Basically, the problem comes from having to use the join statement when creating the xml - you can't really put both the label information and the value information on the same row in the xml.
To get round this, you have to use two internal parameters to create two datasets - one for the labels column, one for the values column. The method for creating these is essentially the same as that shown above, except for the values parameter, the expression for the default value is:
...and for the labels parameter, it's this:
(by the way, make sure you set the available values to "None" for internal / hidden parameters - the expressions here are for the default values)
Then, when you create the values dataset, you use the following syntax in its query:
...and similarly for the labels dataset.
Finally, in the report, you create one matrix from each of the two datasets, then put them next to each other, using fixed row heights and setting "can shrink" / "can grow" to false so that they look like they're in the same table:
I hope this helps somebody!
I downloaded a record of all the people on the first fleet from this website. http://firstfleet.uow.edu.au/download.html
I downloaded the Excel and imported it into Access. In the document, certain people’s age is not known so they are simply put as -1.
I am trying to make this table but I am struggling.
I’ve tried doing it by creating a table but that was too hard so I decided to create a query instead. I am using “Crosstab” but failing to use it successfully.
When I do try to sub the -1 for unknown:
Messages like this pop up:
How do we add the table in but sub the -1 for unknown while keeping the layout the same? I am hard stuck at a place where I cannot even view how my query looks.
How do I even make the layout the same as the picture shown above?
UPDATE:
Calculate the age groups with Switch() function and use that calculated field for CROSSTAB RowColumn. I renamed the Age field in table from the original import name to shorten the expression.
TRANSFORM Count(Convicts.ID) AS CountOfID
SELECT Switch([Age]=-1,"Unknown",[Age]<15,"10-14",[Age]<20,"15-19",[Age]<25,"20-24",[Age]<30,"25-29",[Age]<35,"30-34",[Age]<40,"35-39",[Age]<45,"40-44",[Age]<50,"45-49",[Age]<60,"50-59",[Age]<100,"60-99") AS AgeGrp
FROM Convicts
GROUP BY Switch([Age]=-1,"Unknown",[Age]<15,"10-14",[Age]<20,"15-19",[Age]<25,"20-24",[Age]<30,"25-29",[Age]<35,"30-34",[Age]<40,"35-39",[Age]<45,"40-44",[Age]<50,"45-49",[Age]<60,"50-59",[Age]<100,"60-99")
PIVOT Convicts.Gender;
The total row is added by clicking the Sigma(Totals) icon on the ribbon when query is in Datasheet view.
A simpler calculation will generate more groups:
TRANSFORM Count(Convicts.ID) AS CountOfID
SELECT Partition([Age],0,100,5) AS AgeGrp
FROM Convicts
GROUP BY Partition([Age],0,100,5)
PIVOT Convicts.Gender;
But a little adjustment to the SELECT clause will get same output as the first:
SELECT IIf([Age]=-1,"Unknown",IIf([Age]<50,Partition([Age],0,50,5),IIf([Age]<60,"50:59","60:99"))) AS AgeGrp
Could add a field in table and use one of those expressions in UPDATE action SQL to add calculated AgeGrp, which would simplify the CROSSTAB and other queries needing that group identifier.
I'm using an embedded data source of type SharePoint List.
I use a parameter that a user can modify that will filter the data set by the month. I've seen a few examples but they all either use a SQL query or only filters on the exact day rather than the month.
I added a parameter ParamMonth and gave it the data type of Date/Time. I can see this adds a drop down box to my report which is exactly what I want. Ideally, I would like to add the name of all 12 months or something similar, but I don't know how that will work out when the data exceeds a single year. Now, that I've got my Report Parameter added, I need to add it to my dataset to filter on. This is where I'm stuck.
An easy way could be creating a parameter type Integer and set all months in Available Values tab as follows (I just set five months for example).
Then go to the DataSet Properties / Filter tab and use the below settings.
For expression use:
=MONTH(Fields!Date.Value)
Where Date is the field that you will use to filter by month. In Value you have to use:
=Parameters!Month.Value
UPDATE: Provide year selection.
The best approach for this is getting the available values from a DataSet, in this case your SP list.
Just create a calculated field in your dataset with available years (it can be a copy of the SP list dataset), call it calculatedYear and use:
=YEAR(Fields!Date.Value)
Now create a Year parameter of Intenger data type, and set this settings:
Where DataSet15 is the DataSet name that feeds your parameter with the available years.
Then just add another filter in your dataset:
Note you will need two datasets one to get the available years and
other the dataset you need to filter.
Let me know if this helps.
I am new to JasperReports / Jaspersoft Studio and struggling a bit with Charts. The experts may find it very primitive and it is possible that I could be missing some very basic stuff here.. Here is a brief of what I am trying to do
1) Data source is csv with following fields
Sr_No, URI, total_time_taken, no_of_requests, avg_time_per_req, most_expensive_req, timestamp_of_exp_req
2) The csv has around 40,000 lines in it
3) I want to create a report which has all the 40,000 lines in it (A simple columnar report based on all the fields, sorted by no_of_requests in descending order). This is piece of cake in JasperStudio !
4) Next, I want a summary page with "top 10" URIs in a pie chart where value of the pie series is no_of_requests and key is URI (Pretty straight forward)
I have created a report in JasperStudio with data source as csv. I have selected all the fields and applied no filter to my query for the primary dataset (i.e. the default dataset that I get while creating the report). This helps me print all the 40,000 lines in the "Details" band of the report...so the first part is taken care off.
For summary page I need a pie chart where my challenge is to get "top 10" records from the entire dataset. Thankfully my "top" criteria is based on no_of_requests field and my data is already sorted based on that field. Still, I need a subset of the data to draw a meaningful chart. To achieve this, I tried to create a new dataset with just two fields, the URI (which is the key for the Pie) and no_of_requests (which is the value). I also applied filter expression "($V{REPORT_COUNT} > new Integer(10)) ? false : true" to the my new dataset so that I get "top 10" records from my already sorted data. I verified that the filter is working correctly by running it in "Data Preview" tab of "Dataset and Query" dialogue. I have chosen the new dataset as the "Dataset" for my Pie chart..
When I run the report (in preview mode of JasperStudio), I get 40,00 0 lines printed corrected (in the Details band) but the summary is empty. It draws no pie chart.
I tried same with a Bar Chart, but result is the same. The summary in that case shows just X and Y axis with no data points. The graph is empty.
Am I missing something?
Any help in this regards will be highly appreciated.
I have created two variables which I am gonna use in my pie chart to select the Top N Values from the Dataset. To achieve This I have used $V{REPORT_COUNT} Variable as follows
IF($V{REPORT_COUNT}<=N,$F{Your_Field},"") - If the Variable is a String IF($V{REPORT_COUNT}<=N,$F{Your_Variable},0) - If the Variable is Integer.
Substitute N with your desired number.If you need top 10 values then N=10
Now I have used these two Variables to create my Pie Chart.
I have written a blog for the same as I could not upload images here.
Please do check the same for detailed solution.
http://www.rajeshsirsikar.com/selecting-top-n-values-from-a-csv-datasource-jaspersoft-studio/
I'm working on a rather complex report in Sql Server Reporting Services. My SP returns a dynamic number of columns each of which are dynamically named.
Basically think of a time keeping application. Each column that is dynamic represents a time bucket that time was charged to for that team. If no time was charged to that bucket for the period of time the report covers it doesn't show. Each bucket has its own identifier which i need to be the column headers.
I have an SP that returns this all. It does it by doing a bit of dynamic SQL with an exec statement (ugly i know but I'm on SQL 2000 so a PIVOT option wouldn't work)
I can have an indefinite number of buckets and any or all might show.
I found this - http://www.codeproject.com/KB/reporting-services/DynamicReport.aspx - which is helpful but in the example he has a finite number of columns and he just hides or shows them according to which ones have values. In my case i have a variable number of columns so somehow i need the report to add columns.
Any thoughts?
As long as you know a maximum number of columns, it's possible to do this after a fashion.
First, name the columns with a result from your query, so you can either pass it in to the query or derive it there. Second, just build out the report as if it had the maximum number of columns, and hide them if they are empty.
For example, I had to build a report that would report monthly sales numbers for up to a year, but the months weren't necessarily starting in January. I passed back the month name in one column, followed by the numbers for my report. On the .rdl, I built out 12 sets of columns, one for each possible month, and just used an expression to hide the column if it were empty. The result is the report appears to expand out to the number of columns needed.
Of course, it's not really dynamic in the sense that it can expand out as far as you need without knowing the upper bound.
This can be done. I did this and it works fine.
You don't have to know the maximum number of columns or show and hide columns in my approach. Use a matrix and modify your sp to return dynamic data to the structure mentioned in this blog post http://sonalimendis.blogspot.com/2011/07/dynamic-column-rdls.html
Build 2 related Datasets, first one for the report content, and the second one for the list of its column labels.
The Dataset of the report content must have a fixed number of columns and name. You can allocate some maximum number of columns.
In this example I have the first 2 columns as fixed, or always visible, and a maximum of 4 columns to be displayed by choice through a multivalued parameter, or depends on the query conditions. And as usual, we may have a total as well. So, it may look like this:
Fixed01, Fixed02, Dyna01, Dyna02, Dyna03, Dyna04, Total
The second Dataset with its values will look like this:
Name Label
---- -----
Dyna01 Label01
Dyna02 Label02
Dyna03 Label03
I have omitted the 4th Label to demonstrate that not all columns are being used by a certain query condition. Remember that both Datasets are meant to be related to the same query.
Now create a parameter named, say, #columns; populate its Available Values and Default Values with the second Dataset.
For each of those 4 dynamic columns, set the column visibility with the following expression:
=IIf(InStr(join(Parameters!columns.Value,","),"Dyna01"),false,true)
And for each of their column header Text Boxes, use the following expression:
=Lookup("Dyna01", Fields!Name.Value, Fields!Label.Value, "dsColumns")
As for the Total, here is the expression for its visibility:
= IIf(InStr(join(Parameters!columns.Value, ","), "Dyna01"), false, true)
AndAlso IIf(InStr(join(Parameters!columns.Value, ","), "Dyna02"), false, true)
AndAlso IIf(InStr(join(Parameters!columns.Value, ","), "Dyna03"), false, true)
AndAlso IIf(InStr(join(Parameters!columns.Value, ","), "Dyna04"), false, true)
And here is for its values:
= IIf(InStr(join(Parameters!columns.Value, ","), "Dyna01"), Fields!C01.Value, 0)
+ IIf(InStr(join(Parameters!columns.Value, ","), "Dyna02"), Fields!C02.Value, 0)
+ IIf(InStr(join(Parameters!columns.Value, ","), "Dyna03"), Fields!C03.Value, 0)
+ IIf(InStr(join(Parameters!columns.Value, ","), "Dyna04"), Fields!C04.Value, 0)
That's all, hope it helps.
Bonus, that second Dataset, dsColumns, can also hold other column attributes, such as: color, width, fonts, etc.
I think the best way to do it is add all the columns in your table and edit the visibility property of it with the help of arguments that you get from your SP..this will solve the purpose of dynamic column but when viewing the report you will get a lot of white-space which you can solve with SSRS - Keep a table the same width when hiding columns dynamically? and your report will be ready
I've had the need to do this in the past and the conclusion I came to is "you can't", however I'm not positive about that. If you find a solution, I'd love to hear about it.
An issue that comes to mind is that you need to define the report using the names of the columns that you're going to get back from the stored proc, and if you don't know those names or how many there are, how can you define the report?
The only idea I had on how to do this is to dynamically create the report definition (.rdl file) via C#, but at the time, I wasn't able to find an MS API for doing so, and I doubt one exists now. I found an open source one, but I didn't pursue that route.