Changing background color of birt report according to groups - scripting

I am generating a BIRT report as shown by image embedded, I am grouping by custmeer such as ACM , AFL etc ...
As you can see I use background alternative color as blue and white, to achieve this I simply use the highlight tab of detail row as(row["__rownum"] % 2 Equal to 0).
now , if I move into more complexity such as different color combination for different groups e.g for group(customer in this case) yellow-white, for group2 red-white etc....
I am using this.getStyle().backgroundColor ='color', but the problem lies into selecting the individual groups, may be some sort of in condition would do the trick, but I am lost

The simplest way to set a row's background colour in BIRT is by adding conditions to the list in the Highlight tab within the Property Editor for the row. It looks as though you have already done this to set alternative lines to blue - by adding extra conditions with additional colours, you can set the background accordingly. This method is most useful where only a small number of colours are required, since you have to set up a different condition for each colour.
Where a larger selection of colours is likely to be required, it would make more sense to do conditional formatting within an event script - you can find an example here.
EDIT: Adding a running group count in BIRT:
Add an aggregation item to your table - you can do this by dragging an aggregation item from the Quick Tools section of the Palette, for example.
In the Aggregation Builder dialog, set the Function to be COUNT, the expression to be 1 and the Aggregate On to be the group you want to count (eg. Customer)
Insert a second aggregation item with the Function set to be RUNNINGCOUNT, the expression to be 1/row[first aggregation name] and the Aggregate On to be Table.
The second aggregation item will be a running count of the groups in the report.

Related

Spotfire calculated column based on filter

I want to create a calculated column that is equal to the percent of the total of the previous column, but only for the rows that are selected.
For example, the two columns below show rows where I've filtered for only the rows of interest. The sum is accurate, but I want the percent of the total to be only out of sum of the currently selected rows rather than the absolute total (which is how it's currently being calculated). I want the percent of the total to dynamically change depending on what is filtered in the data table. Is this possible?
Image of my 2 columns:
I know spotfire somehow calculates this becuase when I insert a bar graph using % of Total(SumofComponents) the ratio is only out of the current total.
Image of my bar chart:
much like in programming, Spotfire has a rough concept of scope. and unfortunately, calculated columns are above filters in terms of scope; they have no concept of what is and is not filtered.
visualizations themselves, however, do*!
what you can do in this case is to put your expression on the Y axis (it looks like you've done this), and it will respect your selected filters*.
*caveats: there are a few ways that filtering can be negated on a given visualization:
Properties>>Appearance>>Show shadows indicating the unfiltered data. this option shows a grey bar that represents the data hidden by whatever filter selection was made
Properties>>Data>>Limit data using filterings. these options allow the viz to use separate filtering sets ("Filter Schemes" as they're called in Spotfire) or none at all (to ignore filters completely)
Properties>>Subsets. by default there are three subsets: "All Data" which ignores filters, "Not in current filtering" which inverts the filter selection (e.g., if you filter a boolean column to show only TRUE, this chart would show only FALSE), and "Current filtering" which is the default behavior. you can check the online help for additional subsets that you can add.

Toggle groups based on a parameter

I have a reporting requirement in which I have 3 groupings
Group_1 parents -> Group_4 lowest child
I have a groupingID param which is an int that I'm using to show the same report either as region/div or emp/supervisor. Group_1 =totals and Group_4 = Employee and NULL for region/division.
Updated requirements want me to not show toggle button at Group_3 = Region level if GroupingID is set to region/division. As region is the lowest level.
While still show toggle "+" button if grooupingID param is emp/supervisor.
I tried this expression for "row visibility but to no luck.
=iif(Parameters!GroupingID.Value=1,True,iif(Fields!Group_4.Value=Nothing,True,False))
This expression shows + for Reg/division report.
Row visibility is more for whether or not you want to show a particular row. When I've had a need to show a summary and detail, I would make 2 tablixes and show/hide the proper one based on my parameters.
I'm not sure if you can conditionally change grouping sets via row level expressions, but if you could, it would probably be a lot more ugly than doing separate tablixes. Down side to this approach is that you have 2+ tablixes that are similar to maintain.
Data Architect proposed a solution which solved it. Add a new column in tablix to the left of all the groupings.
Depending on which group level you wish to toggle (in my case at group_3) just use the text box (to the left) of group_3 text box as 'toggle item by' in the properties for group_4. This solved the issue I was having.

How to make rows invisible while printing reports?

I am using an .rldc file to define the layout of the reports from my program. The problem is, it is to be used for incremental printing. That means the paper will be used over and over as newer rows need to be printed. I'm attempting to approach it this way:
List all corresponding data on the report view.
Make the older rows invisible and only show the latest row.
Print.
That way, the last row is already properly placed. The problem is, I don't know how to implement this. Can anyone help me out?
You could create an IIF(condition,true,false) statement in your report definition on the row visibility variable.
The best way i guess is to define in your data source something of a rank column.
example :
select col1,col2,col3,RANK() OVER (ORDER BY col3 DESC) AS 'rank' from table1
Then in your table or matrix, you click on the row or/and column that you want to make the borders and text white based on a expression.
Go to the properties and dropdown on bordercolor
choose expression and type in (based on my example query)
=IIf(rank.value <> max(rank.value),White,Black)
That will not remove the rows only make the borders white ( unvisible)
The same you can do with Font Color property.
I think this is your best shot at this issue.
Other solution I could think of is to just hide unneccesary rows (which also replaces the visible row)
Then to move the table down by using a expression with a formula like nr of rows hidden before the actual row * height of 1 row, only I m not sure if this is applicable without programming an RDL extension..
Good Luck !

how to prevent some columns from being highlighted when selecting a row

I have a semi-dynamically created window ( and use PowerBuilder 10.5 ). Now there are a couple of columns which can have different colours and I want to see those colours when selecting a row. However I don't know how to deselect these columns and have the first couple of columns remain selected.
The highlight function in our application just does a dw.selectrow( x, true ).
Regards,
Marinus
I don't think you'll get what you want using selectrow. If you don't need multiple selections you could change the background of the current row with an expression in the datawindow. If you want some columns to stay normal you could do that with a rectangle behind the ones you want to highlight instead of changing the row color. If you need multiple rows highlighted you will have to simulate multi-select by adding a dummy column and using that to control the background, and of course you need to handle the selecting and deselecting in the clicked event. If you've got code that deals with selected rows you'll have to change them to use the new scheme, for example by checking the value in your dummy column.
If you want to use SelectRow(), maybe use of SetRowFocusIndicator() would help. IIRC (it's been pretty close to decade*s* since I've used it), it disables the row colouring in favour of the new method.
The other way that comes to mind is setting an expression for background colour that uses GetRow() and CurrentRow(). This wouldn't be my first choice, as it doesn't let users with vision impairment choose their colours through standard Windows colour selection to something they can deal with, but if you're dead set on colour indications on selective columns, this would be the way to go.
Good luck,
Terry.

Automatic Chart Pagination with Report Parameters

Based on several report parameters in SQL Server 2005 reporting services, I would like to automatically generate one or several chart(s) for each row in the return result and paginate or space them out. How do I go about that?
If the number of charts will vary for each row, but the variations are known (e.g. it's either just chart 1, or chart 1 and 3, or charts 1 2 and 3) then it's simple enough using a table.
In the default detail row add any normal fields you need. Now insert a new detail row for each chart you might need. Lastly set the visibility of each chart row based on your rules, noting that the rule will hide the row if your expression evaluates to true. Make sure you select the row using the area to the left of the left-most cell, if you got it right you'll see that it's a row in the properties grid.
To get the layout you want you can merge cells for the charts to go in, or use a single cell and put a Rectangle in it, then in the Rectangle lay out your other controls.
Any rows that are hidden will be collapsed, so you wont get big empty sections like you can if you simply toggle the visibility of the charts themselves.
What you can do is place a List control on the page, set List grouping by record unique key (ID, or several fields if composite), and place a charts on the List. Next, set items visibility expressions to control it with report parameters.