Jaspersoft Studio : issues while drawing graph - csv

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/

Related

Microsoft Report Builder: How to display selected chosen values from a multi-value parameter in a table?

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!

SAP Web Intelligence - Summary Column Based on Multiple Criteria

I'm new to SAP Web Intelligence and I'm trying to create a report with a summary column based on multiple criteria. Below is my desired output in Excel as an example. I am having trouble coming up with ways to create this summary column (col H)
Link to the example here.
Essentially, I need column H to do the following:
Score = 0
For each cell in Range C:G, if cell isn't empty, get amount of points test is worth based on region the user is in, and add that score to "Score", and show in Column H as a total at the end.
Is this possible in SAP WI? I really really appreciate any help with this (even a push in the right direction).
Thanks!
I believe you're looking for a compounded IF function in a Variable here.
If you're used to using Excel, you will recognise the similar syntax for it:
=IF(TEST;Value if true;Value if false)
You will want to compound that so that you have and IF based on the 'Region' followed by a list of IF statements for each test that add up the points, followed by another list of IF statements for each test based on the other 'Region'
Something like the following should give you the basic start:
=If([Region]="Oceania";If(IsNull([Test #1]);0;1)+If(IsNull([Test #2]);0;1)+IF(...);If(IsNull([Test #1]);0;2)+If(IsNull([Test #2]);0;0.5)+IF(...))
From there you add the relevant test columns into the sums to get the totals for each row.

How to Display Only 1 Value Label in SSRS 2012 Calculated/Derived Series?

I have been using SSRS 2012 (Sql Server Reporting Services) with SQL Server Report Builder 3.0 (11.0.2100.60) to create Column charts that display columns for each day/week/month and display a trend line based on the mean across all days/weeks/months.
However, although the calculated series reflects only 1 value (the mean across all days/weeks/months), value labels appear on the chart displaying the single mean value for each day/week/month - that is, 3 days will result in 3 value labels for the same mean value.
Is there a way to force the series to show only 1 value for each mean trend line?
See below for sample chart.
The work-around I ultimately settled on involved creating duplicate series with value labels but invisible data points (obtained by setting Color to "No Color").
The values for this series are only assigned if the "dayofweek" field matches the first "dayofweek" field in the dataset, so only 1 data label will be displayed (namely, the first one).
For example, to show a single value for the average of the "physio" field for physiological alarms within my dataset ("techphysDayofWeek", I use the following formula):
=IIF(Fields!dayofweek.Value = First(Fields!dayofweek.Value,
"techphysDayofWeek"),Format(( Avg(Fields!physio.Value, "techphysDayofWeek") /
Parameters!StartDate.Value), "##.#"), "")
I wish SSRS provided an easier way, but after struggling with this seemingly simple issue for hours on end, I'm just glad to have any fix!
You can set the label text to be based on a formula. In that formula you could look at the value of the grouping field, and set the text to an empty string if it's not currently the group you want to have the label on.

MS Report Builder 3.0 Gantt Chart - Series Fill Color for distinct values

I have built a gantt chart in MS report builder 3 which reports on a teams currently assigned projects and the expected time of completion. I am trying to fill the series color with the same color where a project name exists more than once, i.e 2 teams can be assigned the same project thus the charts bar should display the same color every time the same project name occurs.
I have tried creating a dataset which returns distinct project names and then create a function on the series fill that switches between each value but I have had no success, as below:
=Switch(Fields!ProjectName.Value IS First(Fields!ProjectName.Value, "ActiveProjects"), "#00000000")
It is also worth noting that these project names will be replaced and updated over time thus the color can't be static and needs to be automatic upon generation of the report.
Can anyone provide a solution for this scenario?
In case anyone else comes across a similar problem I resolved my issue by adding my own column to my original data set.
This value uses the below syntax:
HEX = '#' + RIGHT(LEFT(master.dbo.fn_varbintohexstr(CAST(p.ProjectName AS VARBINARY(10))), 9), 6)
I'm basically using the built in varbinary to hex string function to evaluate a hex value every time a distinct project name exists.
Back to report builder, I simply change the series fill color option to the value of this column.
Hope this helps someone.

How to structure my query for a MS Access Chart?

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