Create a table with a color background in SSRS - sql-server

I need to modify a report in SSRS 2008 that displays a value using a table representation as follows.
The accepted value range is 1-7 and the table changes the background color of the cell in the table. I need to be able to modify the color of the color according to some parameter. I reviewd the code and the report was done by creating 7 images -- with the different bachgrounds -- and hiding all images but the one that matches the prarameter value.
I was thinking on using an HTML table to achive this, but the I found out SSRS does not support the table tag. Any ideas on this??

You can set up BackgroudColor property of the table cell using expression. In the expression return the proper color code based on your parameter, for instance
=Switch(Parameters!yourParam.Value=1, "Red",
Parameters!yourParam.Value=2, "Blue"
...)

I figured it out.
I added 7 Textboxes to the report. I aligned them and set the border values and text to look like the image above. Then, set the color property to something similar to this.
=IIf(Fields!RangeParameter.Value=2,Parameters!ColorParameter.Value,"Transparent")

=iif(RowNumber(Nothing) Mod 2, "#eefafd", "White")

Related

Having trouble with alternate shading and hidden cells in SQL Server Reporting Services

The main method I have for altering the formatting of the final reports is in SQL Server Report Builder.
I have a table within this system which currently is as shown below with some information blacked out.
As shown currently the second line (as shown by 004A) of groupings (referred to as a subsample) comes up with blank areas in the second, third, and fifth columns where the cells have been hidden.
This shading has been done with the following code:
=Iif(Left(Fields!LabSampleNo.Value,3) MOD 2 = 0, "WhiteSmoke", "Transparent")
Is there a way to fix this issue without having to go to coding outside the report builder or by making the fields no longer hidden?
Any help would be great.
As the textboxes are hidden you will not be able to see the backcolor. It is the entire textbox you are hiding, not just it's content.
So the answer to your question is no, you will have to make the textboxes visible again however you can just wrap your value expression inside the same logic as you used to hide the columns.
So, let's say you are hiding the columns based on the first column have non numeric characters and the column you wanted to hide was called myDataColumn then you could do something like...
=IIF(ISNUMERIC(Fields!myFirstColumn.Value), Fields!myDataColumn.Value, "")
Your row's background color expression would remain the same.

How can I handle circular reference error in powerapps when trying to filter selections of two comboboxes depending on each other?

I am using PowerApps to create a small app which contains two comboboxes, which filter information that are being displayed on a data table and come from an excel sheet called Table. More specifically, my first combobox is called ColorCombo and displays distinct values, which come from the column Color of the sheet Table and the second combobox is called SizeCombo and displays distinct values that are contained on the column Size of the Table
My goal is to filter the information of the one combobox depending on the selection of the other combobox.
For instance, I have the colors : [Red, Blue,Green] listed on the ColorCombo and the sizes: [32,34,36] listed on the SizeCombo. If the red color is only available on size 32 then when I select the red option on the colorcombo I want to only see the number 32 on the SizeCombo and if the size 32 is available on green and blue color then when I select it on the SizeCombo I want to only see the options green and blue on the ColorCombo. The code I have so far is:
Sort(Distinct(Filter(Table, If(CountRows(ColorCombo.SelectedItems) = 0,true,
Size in SizeCombo.SelectedItems)),Color),Result,Ascending)
which works ok for the colorcombo. When I add the same statement for the SizeCombo as well though, I get an circular reference error. This is the statement I input:
Sort(Distinct(Filter(Table, If(CountRows(SizeCombo.SelectedItems) = 0,true,
Color in ColorCombo.SelectedItems)),Size),Result,Ascending)
I understand that this is happening because the selection of the comboboxes are depending on each other recursively, so this happens to prevent an infinite loop, but how could I solve this? I appreciate any help you can provide, since I have been trying to find a solution to it since a long time.
Some quick workarounds could be implemented via UI/UX:
Force the user to go through the two boxes sequentially
Start with sizecombo (for example).
Set DisplayMode of colorcombo to If(IsBlank(Size.Selected.Value), DisplayMode.Disabled, DisplayMode.Edit
Adjust the code accordingly.
Another idea: Instead of two comboboxes, have user select a size, then display swatches of Available Colors in a small Gallery. Or vice versa, choose a color then display Available Sizes.
You could accomplish that pretty easily using Filter()

SSRS Matrix Title Being Cut Off

Could someone please explain how I can have the report header (title) expand as far wide as the matrix in the report goes? The title is a textbox and only goes as far wide as I set in the report designer.
I am using SSRS 2017.
You could add a row above the top row of your matrix/tablix and then merge all the cells in that row and make that your report header.
My own solution or better said my workaround, was to set the report background to the colour I wanted and just push the title alignment to the left. Now the background colour fills the width of the report.

SSRS Matrix - Set Color for Pivot Aggregate

I have a relatively simply matrix configured in SSRS. Accounts on the left side and product (well actually product family) on the top. It counts the number of product families represented in an account. Everything works correctly.
Now I want to color code the aggregate ([Count(productid)]). I know how to set background color and text color using a function. What I cannot figure out is how to reference the resulting aggregate value.
You don't need to reference the aggregate directly. If you set the textbox properties (color, background color etc) then any calculations/expressions are within the scope of the textbox, unless you specifically state otherwise.
Let's say you wanted a simple colour coded background. You could set the BackgroundColor property of the cell to an expression like this.
=SWITCH(
COUNT(Fields!ProductID.Value) >15 , "Red",
COUNT(Fields!ProductID.Value) >10 , "Orange",
COUNT(Fields!ProductID.Value) >5 , "Yellow",
True, Nothing
)
As we have not stated the scope, SSRS assumes we mean the scope of the object (the textbox), i.e. the column and row it appears on are taken into account.
The above code on a simple matrix returns something like this.

How to create little colored shape in a cell that would indicate colors on a chart? SSRS 2012

I have a bar chart with different bar colors. Below in a table I just want to indicate what each color means.
Can I do something like that in SSRS?
Im sure I can create another column on a left and assign each color to a cell. But is any way I can display it the way its on a picture above?
I tried to use indicators for that but I guess it needs conditions.
You can do this with custom code.
Loose steps to follow are:
Create a list to hold the graph
Add the graph
Inside the list and below the graph, add a tablix
The tablix will row group on the same thing as the graph (so you can get a row per coloured item in the graph)
Add a column to the start of the tablix for the colour
Add the following custom code:
Private colourPalette As String() = {"#418CF0", "#FCB441", "#DF3A02", "#056492", "#BFBFBF", "#1A3B69", "#FFE382", "#129CDD", "#CA6B4B", "#005CDB", "#F3D288", "#506381", "#F1B9A8", "#E0830A", "#7893BE"}
Private count As Integer = 0
Private mapping As New System.Collections.Hashtable()
Public Function GetColour(ByVal groupingValue As String) As String
If mapping.ContainsKey(groupingValue) Then
Return mapping(groupingValue)
End If
Dim c As String = colourPalette(count Mod colourPalette.Length)
count = count + 1
mapping.Add(groupingValue, c)
Return c
End Function
For the series fill on the graph, use the follow expression:
Use the same expression for the fill on the initial column in the tablix
You can use any list of codes for colour - this is the list for the default palette in SSRS.
This code ensures the same colour is picked each time the same item is used - so in the image the same colour is returned each time the same Category is returned.
The solution I use is pretty simple.
I use Windows Character Map to find a character I like. For example: ■
Copy that character and add an expression where you want to show the color icon. Your expression text will be
="■"
Then go to the Font tab and Color. Select the color you want from the menu. You can use expression logic in here to change the color dynamically. (You can refer to other answer for details there)

Resources