How to use custom code to add Excel-like "color scale" conditional formatting to SSRS report - sql

I am trying to use this custom code in SSRS
public function ColorScaleRYG(value, minValue, maxValue) as string
in a custom code in ssrs
and then in a Fill expression
=Code.ColorScaleRYG(Sum(Fields!SalesAmount.Value), 0, 100000)
which should break my values in a group and assign shades of colors from red(0) to green(max valer).
But for some reason nothing happens/
What am I missing?
I need something like that:

I wont be able to give you the specific answer as it is with your code, however this is how I go about it.
In Design Mode I Right click the required Cell and Select "Text Box Properties.
I then go to the Fill Tab and click on the expression button next to Fill Color.
I then User something like the following code
=IIF(Fields!Total_Eligible.Value>100,"MidnightBlue","Silver")
You should be able to Stack this IIF Commands.
It is just a matter of changing the Fields! field to the approriate variable and then the conditions.
This Returns the following Values
Hope this Helps.
Post Note - Probably dont use these colors as they aren't easy to read , I just grabbed two at random off an existing report to demonstrate.

Related

Spotfire: Need to select all values in a Multi select List Box Document Property

I have zero knowledge of coding. Can someone please help me with code.
My situation is as follows:
Dashboard has a Multi select List Box (Document Property). I am using that to restrict the data and calculations.
User does not want to select values each time. He wants a button where in (s)he click it once and all the values present in the list box gets selected.
Can someone please help me.
Regards,
Subro
This is fairly easy to do. Let us say that the Document Property that the list box is used for is named "Test" and it is of type "String List". Then you can use an IronPython script like so:
Document.Properties["Test"] = ["First Choice","Second Choice","Third Choice"]
Where the string list you see above, are all the values in your list box. Make sure that the strings you assign to the document property are the ones you want to populate your list with, since sometimes the displayed values can be different than the ones assigned to the document property(The case of using the "Fixed Values" option when setting up the control).
Hope that this helps.
Zenios

BIRT result set values in specific cells

My query returns location_cd(string) and item_count(int). I only need certain rows from the result however and I need them to display in specific places in my layout so I don't think the table solution is going to work. Can I determine where I place the value for a particular row of the result set?
I am using a grid to display values for a number of fields. I cannot seem to be able to get the values from the results to show. The grid is bound to the result set. I even tried binding the cells to the result set but that didn't work either.
I checked in the query editor and there is a result set shown in the Preview so I know the query works. The complete and correct result set shows if I put a table on the page.
I tried inserting a Dynamic Text or Data object in a cell and used the expression:
dataSetRow["location_cd"]=="3SD"?dataSetRow["item_count"]:""
This returns a blank and does not seem to evaluate. I tested it with :
dataSetRow["location_cd"]=="3SD"?dataSetRow["item_count"]:"BLANK"
and got 'BLANK' to appear in that cell.
dataSetRow["location_cd"] and dataSetRow["item_count"] will display the location_cd and item_count from the first row of the result set. row.outer[] did the same thing. Obviously I am just hacking at this report at this point.
A co-worker suggested that she uses a JAVA if-statement in places like this but I could not get that to work either.
Any ideas or suggestions that will get me on the right road??
Thanks
An elegant option would be to use a HashMap storing the result of the dataset.
Declare a report variable named "values", with a new hashmap as default value (see image below)
Fill values in the onFetch script of the dataset: vars["values"].put(row["location_cd"],row["item_count"]);
Insert new data elements at any place of the report with expressions such: vars["values"].get("myFavoriteLocationCD");
Though it is important to note the dataset should be triggered by the report before these data elements.
The particular row you want to display you specify in a "Text" field inside your grid. Just drag and drop a "Text" field inside your grid. If you bound the fields you want to display to your grid, the "Text" field inside the grid inherits the bindings of its parent (the grid), so you can access the bindings automatically in the "Text" field.
You could try following steps, maybe that works.
Don't use "Dynamic Text" field, instead use a regular "Text" field
Ensure the fields of your query which you use, are bound to the grid (you sayed you already did)
Open the "Text" field
Change preselected pull-down entry "Auto" into "HTML"
Change preselected pull-down entry "Formatting" into "Dynamic Text"
Wrap your code in <value-of format="HTML"> your code goes here... </value-of>
Note: You should check in the "Expression Builder" of your "Text" field if you are able to access the fields you bound to the grid. If they are not available sth. went wrong with your binding. Avoid binding query records to cells this will drive you crazy.
If you want to display a list, ensure you didn't set a constant height in the row of your grid. Set the height to 100% than the row takes its height dynamically.
What about the idea to optimize your query, that only get the results you want are displayed, than you don’t need to filter them with java script? If you don’t need the filtered results in another place this would be the cleaner solution in my opinion.

In Livecycle forms make all negative values red

I'm building a form in Adobe Livecycle and would like all negative numbers to display in red. I can accomplish that on individual elements by attaching this code to the exit event:
form1.#subform[0].Table3[0].HeaderRow.concessions1::exit - (FormCalc, client)
if ($.rawValue <0) then
$.font.fill.color.value = "255,0,0"
else
$.font.fill.color.value = "0,0,0"
endif
Currently I have to add this code to every single field, is there a way to make this script run on multiple fields without retyping it for each one?
Thanks
your options are:
Externalize the code in a script object and call the method on the exit event. You can pass the field as an input parameter so that your code is generic.
If you want to do this before a form is submitted, you can create a method that loops through your form fields and reference this code to highlight the negative values.
I hope this helps. Let me know if you have any more questions.
Thanks,
Armaghan.

Hide text box based on parameter values

Hope someone can help as I am quite new to SSRS, I am trying to hide a text box that has an expression in it. When multiple values from a drop down parameter are selected I want to hide the box but when only one option is selected I want to show just the one option.
I currently have a text box with the following expression in it
=First(Fields!Name.Value, "ABC")
The above currently shows the first Value from a field which is correct, but when as I said there are more values selected, I want to hide this, I am not sure if I need to wrap the above expression in something or change this in the Text Box properties under visibility
I have been trying to add the following expression under the Text Box Properties/Visibility option, but not having much luck
=Iif(Parameters!Supplier.IsMultiValue > 1, True, False)
I am using SSRS 2012 though I am sure what I am trying to do is quite easily done in every other version.
Hope someone can help, P
As a multi value parameter is an array, you need to use a formula like this:
=Iif(Parameters!Supplier.Value.Length > 1, True, False)
or as suggested by the OP
=Iif(Parameters!Supplier.Count > 1, True, False)

Gray out a form row's (detail's) button conditionally with VBA code

I have a standard form in MS-Access which lists a bunch of orders, and each row contains order no, customer, etc fields + a button to view notes and attached document files.
On request from our customer we should gray out the button btnAnm (or check or uncheck a checkbox) depending on a calculation from two queries to two other tables (a SELECT COUNT WHERE and a check if a text field is empty).
I've tried btnAnm_BeforeUpdate(...) and btnAnm_BeforeRender(...) and put breakpoints in the subs, but none of them trigger. The same if I use the control Ordernr instead of btnAnm.
I'd like a function in the Detail VBA code to be triggered for each "Me." (row) so to speak, and set the row's control's properties in that sub.
What do I do? I've looked at the help file and searched here.
*Edit: So I want to do something that "isn't made to work that way"? Ie. events are not triggered in Details.
As an alternative, could I base the value of a checkbox on each line on a query based on the 'Ordernr' field of the current row and the result of a SELECT COUNT from another table and empty field check?
Do I do this in the query the list is based on, or can I bind the extra checkbox field to a query?
A description of how to do this (combine a COUNT and a WHERE "not empty" to yes/no checkbox value) would be perfectly acceptable, I think! :)*
You cannot do much with an unbound control in a continuous form, anything you do will only apply to the current record. You can use a bound control with a click event so that it acts like a button.
Presumably the related documents have a reference to the order number that appears on your form, which means that you can create a control, let us call it CountOrders, with a ControlSource like so:
=DCount("OrderID","QueryName","OrderID=" & [OrderID])
The control can be hidden, or you can set it up to return true or False for use with a textbox, you can also use it for Conditional Formatting, but sadly, not for command buttons.
Expression Is [CountOrders]>0
You can also hide the contents and add a click event so that is acts in place of the command button. Conditional Formatting will allow you to enable or disable a textbox.
As I understand your question, you have a continuous form with as command button that appears on each row - and you'd like to enable/disable the button conditionally depending on the contents of the row.
Unfortunately you can't do that. It seems that you can't reference the individual command buttons separately.
Having wanted to do something similar in the past I came up with two alternate ways of setting up my interface.
Put a trap into the onClick code for the Button. Which is icky, because it is counter intuitive to the user. But it gets you that functionality now.
Move the command button (and editable fields) up into the form header, and make the rows read only. Your users then interact with the record only in the header, and select the record they want work with in the list below. As I recall this is known a Master-Detail interface.