Create uneven chart intervals in Birt - reporting

I have a pie chart in BIRT and about 80 data points. I'm looking to group them in three catagories <17 17-20 and >20. To be more specific I'm trying to make a red yellow green chart.
How can I do this. I tried the grouping function, but it only allows even intervals that I can find.
Thanks,
Buzkie

Use a CASE expression in your query to produce a derived column:
SELECT someval, CASE WHEN (someval < 17) THEN 'Red'
WHEN (someval >= 17 AND someval <= 20) THEN 'Yellow'
ELSE 'Green' END AS wedgeColor
FROM sometable
and then you can bind the pie chart in BIRT to the derived column instead of the actual data point value.

Related

BIRT - How to insert different data set rows in different places in a single text element

I'm developing a BIRT report and this is my situation.
I have one text element, let's say this:
blue square: 111
blue triangle: 222
red circle: 333
At the moment is static, and always displays the numbers you see. I would like to make the numbers dynamic so I created a SQL query and I have embedded it in a dataset. Let's say this is the output:
color shape count
blue square 123
red circle 456
blue triangle 789
I would like to set it up in such a way that each data set row matches the correct row in the text file, so it would become:
blue square: 123
blue triangle: 456
red circle: 789
And will be automatically updated.
I've binded the text element with the dataset and wrote this as a test:
blue square: <VALUE-OF>if (row["color"].toUpperCase() == "BLUE") { row["count"] }</VALUE-OF>
blue triangle: 222
red circle: 333
But when I run the report it doesn't work and the value is blank.
What am I doing wrong?
Thank you all for the help and let me know if you need more info.
You now have a dataset with row[color], row[shape], row[count] to simplify your desired output I would add a "computed column" to your dataset.
e.g. row[output] = row[color] + ' ' + row[shape] + ': ' row[count]
Once you added the computed column just drag and drop your dataset into your report (where you now have the text element) and delete the unused columns.
Tip: if don't know "computed columns":
  use Google image search for "bird computed column example"
  the Google text search might get you lost in birt forum lists.
Update:
It’s possible you have some typo in your scriptlet. In BIRT a scriptlet resolves to the last expression within itself.
Your scrptlet <VALUE-OF>if (foo) { bar }</VALUE-OF> doesn’t have a last expression. (It's not wrong but BIRT may not "understand" it this way) Try instead <VALUE-OF>var result = ''; if (foo) { result = bar }; result;</VALUE-OF> and format the scriptlet to several code lines with result; as last line. This is the same as if we consider the scriptlet as a function in some programming language and the last line of the function would be return result.

Sorting stacked bar chart based on the values ( highest to lowest) in Tableau

I am using working on Tableau stacked bar chart.
The bar chart represents the total %. Therefore, the length of bar chart is equal.
Now I would like to sort the dimension (referee) based on the values of legends ( highest to lowest).
can anyone suggest me how to do it.
I also attached the packaged workfile here
Here is the picture of sort screen;
Level of data source below:
Below is the screen shot based on the final answer provided:
Thanks,
Zep
So to get this you first need to get a calc field that gets the win %:
SUM(IF [FTR] = 'AWins' OR [FTR] = 'Hwins' THEN 1 END)/COUNTD([Game ID])
This can then be used to rank the referees:
Now the reason that it may not be working for you with your technique is that you're sorting on COUNTD(Wins) which is the total number of wins, not the percentage wins for the ref. So someone that has just played more games may come up higher in the rank
Now you have the calc field, you can go back to your report and sort on the new field:
I rearranged the legend so you can see that the ref with the best % wins are shown first (red and blue bars)
If you don't want it sorted by win %, then change the calc field to:
SUM(IF [FTR] = 'AWins' OR [FTR] = 'Hwins' THEN 1 END)
For the COUNTD of games, if you only have the date and the game available and want to create an ID from that that is unique, create a calc field like this:
game-date-id = STR([game]) + STR(' ') + STR(date)
This will then be used in your COUNTD if statement:
SUM(IF [FTR] = 'AWins' OR [FTR] = 'Hwins' THEN 1 END)/COUNTD([game-date-id])
I have attached the picture of the dashboard.
I want to sort the referee based of Hwin
Yeah. It did not work out as expected

Qlikview - bar chart with multiple dimensions

I have straight table with lot of data...
I need to create bar chart from this table - dimension to be year and expressions Column(1)-Column(2).
column(1) = sum(Saldo)
column(2) = sum(Saldo)/3
I try to set dimension to be year and expresion
sum(sum(Saldo) - (sum(Saldo)/3))
but I don't get same total like I get sum of rows of Column(1)-Column(2).
This is because I need to include in dimension Line.
How can I create bar chart with dimensions I have in straight table...?
Any idea?
You need to use AGGR function:
sum(aggr(sum(Saldo) - (sum(Saldo)/3),Document,Line,Item,Unit))
or just use plain math:
Sum(Saldo * (2/3)) or Sum(Saldo)*(2/3)

Dynamically Changing Color of myDBR Stacked Bar Chart

Good Morning,
I need to dynamically set the colors of segments of bars in a MyDBR Stacked Bar Chart. My task is to display the elapsed times that different engines have on or off over the course of a day.
I almost have what I need in a stacked bar chart using just the first three fields, here However, I need the 'on' segments of a bar to be green, and the 'off' segments to be red, based on the values in a fourth field, 'Ignition'.
I have a MySQL procedure that returns a result set with four fields:
Engine DateTime Elapsed Ignition
111 2015-01-02 01:03:12 01:03:15 On
I think I almost have the answer with the following code:
select distinct 'dbr.chart.options', 'bar_segment???', Ignition, '0xFF0000'from resultset??? where Ignition = 'Off'
select distinct 'dbr.chart.options', 'bar_segment???', Ignition, '0x00FF00'from resultset??? where Ignition = 'Off'
Any help will be much appreciated,
mleary2001
Got some great help from the myDBR folks to come up with the answer.
/* call stored procedure to make myTable, described above */
CALL stored_procedure;
/*myDBR chart code */
select 'dbr.chart', 'StackedBar';
select 'dbr.chart.options', 'label_color', DateTime, if (Ignition='On', '0x42B64A^', '0xE85854') from myTable;
/* select data from the temp table created above */
SELECT
Asset,
event_date,
Elapsed,
Ignition
FROM
myTable;
This results in a Stacked Bar Chart with the bar segments dynamically colored as required. :)

NVD3 X axis incorrect ordering (dates)

I'm trying to visualize 2 series but when I visualize them together, the dates don't go in sequential order anymore.
Here is the fiddle: http://jsfiddle.net/hohenheim/6R7mu/21/ Notice the weird x-axis.
Is there a way to fix the x axis on nvd3?
The data looks like this:
data1 = [{
"date": 1396828800,
"impressions": 49145385
}, {
"date": 1396915200,
"impressions": 46704447
} ....
The NVD3 "multiBarChart" uses an ordinal (category) scale, so it will only display the x-values you give it, in the order in which they are added to the scale. Because your two series only partially overlap on the x axis that's causing problems.
Unlike other NVD3 chart types, the multiBarChart doesn't give you the option of setting your own scale -- it needs to use an ordinal scale in order to generate even widths for the bars. However, you can set the x domain (the list of categories to use for each bar), by calling chart.xDomain(arrayOfXValues).
The array will need to be an ordered array of Date values that spans your data. In order to generate it, you'll need the d3 time intervals range functions. You might also need the d3.extent function to find your max and min values.

Resources