Add alternating row color to group on SSRS report - formatting

I am trying to add alternative colours on the column in my report. I have a matrix with a group on the column I want to alternate. I've used the following within the report properties code:
Private bOddRow(10) As Boolean
Function AlternateColor(ByVal OddColor As String, ByVal EvenColor As String, ByVal Toggle As Boolean, ByVal Type AS INTEGER) As String
If Toggle Then bOddRow(Type) = Not bOddRow(Type)
If bOddRow(Type) Then
Return OddColor
Else
Return EvenColor
End If
End Function
And the following within the cells background colour property
=code.AlternateColor("White","Silver",0, 1)
From the following thread -
Add alternating row color to SQL Server Reporting services report
My table is set out as follows
table example
The [VALUE] field is the cell I'm adding the colour formatting to. For the table example the colours are coming out in a checkerboard effect. However another table I have where the row group and column group are switched ([MATCHING_NAME] and [NAME]) it works fine. I can't figure out why, any suggestions?

Why not just stick with something simple like:
=iif(RunningValue(Fields!FieldName.Value,CountDistinct,Nothing) Mod 2, "LIGHTBLUE", "SILVER")
Source: https://www.mssqltips.com/sqlservertip/3490/alternate-row-background-color-in-sql-server-reporting-services-tablix-and-matrix/
It even explains about separate grouping alternating colours which is what you are after.
It also shows you how to do it based on whether it is a table or it is a matrix.

Related

Updating Fields in a Table with Values from Query

I'm struggling to understand why my event code for updating a Microsoft Access form field is only half working.
I have a query, we'll call DataQuery, that selects 3 column values from what we'll call Table1 that looks like the following:
**Part** **Description** **Revision**
10-123 Descrip1 A
10-342 Descrip2 D
10-232 Descrip3 E
I have another table where I'd like to assign the values from description and revision to fields in another table, we'll call Table2, based on picking a value in a combo box.
For instance:
We select a value of 10-342 in our combo box, then the values "Descrip2" and "D" get assigned to fields in Table2.
I can get this to work for whatever column I have in position one, but not position two.
My small vba code:
Private Sub ComboBox_AfterUpdate()
Me.DescriptionField_Table2 = Me.ComboBox.Column(1)
Me.RevisionField_Table2 = Me.ComboBox.Column(2)
Me.Requery
End Sub
Where "ComboBox" row source is DataQuery mentioned previously.
As stated, "Me.DescriptionField_Table2 = Me.ComboBox.Column(1)" works as intended, but the second line seems to be getting ignored. I feel like I'm missing something super simple here, but I'm can't figure it out.
I knew this was something simple...
Gustav, in the comments, answered my issue:
Set property ColumnCount of the combobox to 3.

What Does SET CSPACE=1 Do in SQL/KBSQL

What does this do? I'm using KBSQL but suspect this instance would be identical to SQL.
CSPACE is a column modifier to control the display format in a SELECT or WRITE clause, and is mutually-exclusive with the modifier COLUMN. It takes an integer, and controls the number of blank characters to display between columns.
SET CSPACE = 1 creates one space between each column.

Replace null with zero in crosstab query in Telerik

I just created 2 cross table using wizard function of Telerik Standalone report designer tool
since ISCED 5 has values for private and public its showing properly
using same query I created second cross tab and
but since ISCED 6 table doesnt have values for "public" section its showing like this
how to show as zero for public section 2nd cross tab (when no values for specific row)
You should modify the value of the field using an expression to evaluate your condition.
Select the textbox containing the data corresponding to the column you like to format when the value is null.
In the property pan on the right select "Value"
Write in there your expression, it should be something like this:
=Iif(Fields.MyField IS Null,"0",Fields.MyField)
You should also consider if the value instead of null is empty and eventually cover this case in the expression if applicable.
= Iif(Fields.MyField IS Null OR Fields.MyField = "", "0", Fields.MyField)
More information on conditional formatting can be found here.
Let us know if this works for you.

How to create list as a parameter in SSRS?

I have a report in 2005 SSRS which I want to add a parameter to. The parameter would be comprised of a group of zip codes, but be selected as a single item in the list.
For example, I would like to have 5 zip codes as one selection in the list and 3 for another, etc:
Select 11111,22222,33333,44444,55555,66666 AS Boondock
Select 77777,88888,99999 AS Timbuck
Select Zip Codes NOT IN (11111-99999) AS Everything Else
So my selections in the dropdown would be:
Boondock
Timbuck
Everything Else
Can anyone help me with how I should go about creating this parameter?
Create a simple string parameter to present to the user. Let's call it ZipCodeSet.
Create a dataset that examines the #ZipCodeSet parameter and returns the appropriate list of zip codes. Call it ZipCodeSelection.
Create an internal multivaue parameter that uses ZipCodeSelection as both its Available Values and Default Values. Call it SelectedZipCodes.
Use SelectedZipCodes in your report's datasets.
The easiest solution here would probably to use a Calculated Field on your dataset, called LocationDescription, for example:
=SWITCH(Fields!ZipCode >= 11111 and Fields!ZipCode <= 66666, "Boondock", Fields!ZipCode >= 77777 and Fields!ZipCode <= 99999, "Timbuck",True, "Everywhere Else")
The lone true statement at the end is due to the SWITCH expression reading left-to-right and exiting once it evaluates one of the switches as TRUE. This way for each of the items in your table of ZipCodes you will always end up with a TRUE result.
I assume you're evaluating a range of ZipCodes, and not exact values of 11111,22222, and so on? If so, the switch will have more values. A sample of your data would help if you want an exact answer.
Once you have built your Calculated Field, you can then set up a Parameter (called #LocationParameter) with available values based on a query of your LocationDescription field, then just filter your dataset using:
Expression:
= Fields!LocationDescription
Operator: =
Value:
#LocationParameter
(if you want multiple selections on your parameter, change the operator to IN)
Hope that helps.

How to exclude one value from a grouping sum, based on a value of another field?

How do I exclude one value from a grouping sum, based on a value of another field?
ie I open Report=> Report Properties=>Code and insert my Custom Code, but how would I change the below code to exclude a numeric value of another field for the below case?
Public Function ChangeWord(ByVal s As String) As String
Dim strBuilder As New System.Text.StringBuilder(s)
If s.Contains("Others") Then
strBuilder.Replace("Others", "Other NOT INCL")
Return strBuilder.ToString()
Else : Return s
End If
End Function
I'm assuming you want to exclude a numeric value from a sum where the string value of a cell on the same row includes "Others", and that the function you've supplied is used as the grouping criteria for a table in the report. Apologies if this isn't correct.
It's not going to be possible to do this without using a second piece of logic, either a function or an Iif condition. I don't have SSRS available to test this at the moment, but (assuming your value column is an integer, the code will look something like:
Public Function ExcludeOthers(rowDesc As String, rowVal as integer)
if ChangeWord(rowDesc) = "Other NOT INCL"
Return 0
else
Return rowVal
end if
End Function
Then, in the cell where you want the conditional sum to appear:
=Sum(ExcludeOthers(Fields!desc.Value,Fields!val.Value))
Alternatively, you could do this without the function by using Iif in the cell where the conditional sum will appear:
=Sum(Iif(ChangeWord(Fields!desc.Value) = "Other NOT INCL",0,Fields!desc.Value))
Depending on the nature of your source data, you could also do this by adding calculated columns to the report's source query.
I would favour the second or third option - custom code seems like overkill for this purpose.