SSRS Colour Fomatting across multiple columns - sql

I've created a SSRS report to examine whether certain fields contain a specific value using a simple case, when statement with the values returned being 'Yes' or 'No'. I'd like the cells to be coloured yellow with the value is a 'Yes'. (See Sample Table).
I know I can do this using the function IIF(Fields!Result1.Value="Yes","Yellow","Transparent") but for a table with multiple columns (>60), is there a way to copy the background colour formatting without having to write the function for each column?

If you want to compare the value of each text box/cell with "YES" then you can use the ME.Value reference.
There is little documentation on ME (https://msdn.microsoft.com/en-us/library/dd255285.aspx?f=255&MSPPError=-2147217396)
=IIF(ME.Value = "Yes", "Yellow", "Transparent")
To access the value of the current text box, you can use the Visual
Basic built-in global Me.Value or simply Value. In report functions
such as First and aggregate functions, use the fully qualified syntax.
Unfortunately, ME does not seem to be fully implemented - it causes errors when used in places that were not created to use ME correctly. An ACTION (i.e. Go To URL) that uses ME will fail with an error of an unknown reference.

Related

Excel Named Range Formula - Not Automatic Updating

I have a table in Excel that has column heading names (e.g. data_type1, data_type2, etc.). The data in this table changes based on parameters entered on another sheet, and they are pulled to charts which update dynamically.
As a convenience to a user who might be using this sheet I have added a 'user specified function' (non-vba) which also plots to one of the charts. By user specified function I mean I have three cells with dropdown lists. Two correspond to the table headings and one has a short list of operations that can be applied between the two selected data types (e.g. a user might select 'dataype1', '+', 'datatype2' which would produce a sum of the two in the final column of my table).
The user specified function is achieved by defining a named 'range/function' to match the drop downs with their respective column headers and then calls evaluate. See below:
=EVALUATE("="&ADDRESS(ROW('Raw Data'!XFD5),MATCH(user_in1,'Raw Data'!$A$4:$AF$4,0)) & user_operation & ADDRESS(ROW('Raw Data'!XFD5),MATCH(user_in2,'Raw Data'!$A$4:$AF$4,0)))
I name this 'user1_result' and then enter =user1_result in the final column of my table. This approach is nice because it calculates much faster than doing the same thing through building a UDF in VBA and then applying that UDF to every cell in a fairly long column.
Now here is my hangup, this works fine initially, but if the user makes a parameter change that affects one or both of the selected datatypes, the user specified column does not recalculate on-the-fly with the updated data. If the user re-toggles any of the dropdowns the data does recalculate. I am speculating this is from one of two things:
1) Excel does not recognize that a precedent of 'user1_result' has changed, and so for efficiency sake doesn't bother to recompute the column;
2) The 'Evaluate' function used in the named definition of 'user1_result' is not checked for updating, because it's not a normal function (doesn't show up through intellisense if you try to just add that to a cell).
So I am looking for some either confirmation or refutation of these speculations. In the case of confirmation I am hoping to get some advice on how to force the user specified column to update if its precedents change.
One solution is to have VBA do this checking for me and force the computation, but I would like to leave that as a last resort. So, non-VBA solutions preferred.
For posterity I'll answer the above question based on Mat'sMug's feedback:
Regarding the cause of the problem:
The reason the user specified column does not update is because the 'Evaluate' portion of the 'user1_result' named formula is intended to be used at the application level and not as a worksheet function. Because of this, Excel doesn't bother checking to see if its precedents change and ignores it for recalculation.
The problem's solution:
It was suggested to use VBA to watch for worksheet_change events, however, my problem requires that I do NOT use VBA. So, an alternative workaround that forces Excel to check precedents and recalculate the user specified function uses two steps. This functions as a pseudo worksheet_change stand-in.
First, I use a helper cell that performs a countif with an arbitrary counting condition. I don't need it to change, I just need it to share precedents with the inputs of 'user1_result'. So I have it count the number of cells in the first row of data that are larger than some constant:
=COUNTIF(A5:AK5,">100000")
The result of this computation doesn't matter, but in my case my data have small values and so this returns 0 always.
Second, I use a condition for the computation in the user specified column (the last column in my data table).
=IF($AO$1=$AO$1,user1_result)
Now, anytime my data table updates, the final column using the named function recomputes. Simple, and if using macros is not viable (for example due to a client/user's security concerns), this can sort of substitute for a worksheet change event.
I hope somebody out there gets use from this!

SSRS hide a row where a expression field value is blank

I have a field in my SSRS report that derives a value based on an expression. The expressions is a simple Lookup between 2 datasets and is working fine. It does return some NULL values and what I would like to do is not display the rows where the expression produces a NULL value. I know how to do this on a field that is not based on an expression but not on a field that is. Anyone know how this can be done? Thanks
Chances are, it will be something like the expression below on the Hidden property of whatever it is you are trying to hide/show.
=IIf(IsNothing(<your Lookup expression>), True, False)
Add any other checking in there too, if need be.
UPDATE:
To make this work on the entire row. Right-click on a row header in design mode, and choose Row Visibility... Click Show or hide based on an expression. Add the expression you now have in there.

Coloring Excel Cell based on a table condition

I am going through the users of a system and reviewing if they have appropriate role names. I then completed an excel table that looks abit like this:
I'm trying to turn the table into a more readable format. I have made a pivot that looks like this:
But I'm not sure how to highlight the cells to reflect the 'Access Appropriate? Yes/No' column. Ideally, it should be colored yellow if the 'Access Appropriate?' = 'No'. I'm thinking of using VBA, but was wondering if there is an easier solution using formulas or pivot table?
Your pivoted data isn't an actual excel pivot table, is it? I know what the x mean, but where do they come from?
Two possibilities come to mind if you want a flexible setup without VBA, aswell as an rather simple VBA-approach that uses an UDF.
Quick'n'dirty (really dirty) would be to
use 1/0 instead of yes/no (you could write that into a helper column with an if-function)
create a new pivot with ROLE_NAME for columns, USER_NAME for rows and SUM or MAX of [Access appropriate] for values
that means: instead of your x you will end up having 1 and 0. Empty cells will still be empty.
conditional format the value-range, e.g. If 1 then green If 0 then yellow if "" then Nothing
Alternatively, you could build your output-table with formulas like INDEX, MATCH and VLOOKUP-formulas.
An additional Key-Column with USERNAME&ROLE_NAME will be needed
conditional format the value-range
VBA: Provided your Rows are distinct a user defined function could do the following
read data into a recordset IF that hasnt been done already (meaning: declared on module-level, the first function call will fill it)
access the data in your recordset with a Recordset.Filter based on your input parameters - USERNAME and ROLE_NAME, in your case
output a certain Field.Value based on your input parameter - Access Appropriate in your case
conditional format the TRUE/FALSE values you get (since this can't easily be done inside an UDF)

SSRS Report Builder: Creating text color expression based on textbox value?

Is it possible to have SSRS look at the value of a text box after calculating it, and then apply an expression to determine the color of the text?
More specifically, I have a lot of different text boxes that contain custom formulas to calculate percentages. Normally, I would create an IIF statement in the text color expression builder like this:
IIF([complex formula]<0,"RED","GREEN").
This works fine, but when you have a ton of these textboxes, each with different formulas, it would be much more efficient to just copy one standard color expression into them like this:
IIF(This.Value>0,"RED","GREEN")
Are expressions like this possible in SSRS?
The answer is yes, if you are using a very recent version of SSRS:
=IIF(Me.Value < 0,"Red","Green")
Link to original article here
Hope that helps.
It's not as clean, but if you need to refer to a different already calculated cell (or self reference for that matter) you can use
=IIF(ReportItems!CellName.Value < 0,"Red","Green")
EDIT: This is actually listed in the link #Randall Mathews posted, which I didn't click until I answered.

Custom code to fix #Error showing in SSRS reports

I have a few reports built using Report Builder 3 for MSSQL 2008 Reporting Services.
Some fields in my report are showing "#Error", instead of this I want to show only a simple "-". Is there any built-in function or custom code to overcome this?
I'd still really like to see your formula but you seem determined not to show it, so I'll take a wild stab at answering without it. I imagine that you are doing something like dividing the field on the current row by the field on the previous row. However, this would give you Infinity on the first line rather than #Error so there is something else going on. But let's run with this anyway since we don't have your formula.
The most common way to solve this is to check for Nothing being returned for the Previous function, usually indicating that you are on the first row (assuming your field always has data). This has the advantage of also working on fields that are not guaranteed to have a value.
=IIF(IsNothing(Previous(Fields!MyField.Value)), "-", Fields!MyField.Value / Previous(Fields!MyField.Value))
Here is another way you could do it using the row number, which will always check for the first row regardless:
=IIF(RowNumber(Nothing) = 1, "-", Fields!MyField.Value / Previous(Fields!MyField.Value))
This assumes that the error is being caused by the Value formula and not by some other mechanism such as applying an expression to other properties like Format, Color which is invalid when there is no previous row.