SSRS Change cell color depending on SUM value - sql

I am loading a dataset into my report and filling my last column with this expression: =Sum(Fields!ID.Value) and it loads fine, I am trying to put a condition in so when the number is less than 15 for example, the cell color will change to red. I have tried so many different syntax but nothing works... it must be pretty simple...?
The errors I am getting are: The value expression for textbox has scope parameter that is invalid for aggregate
Any help would be good :)

To set the background color Click on the cell and in properties window on your right hand select the BackgroundColor property and then set expression to that property.
Or right click on cell and select TextboxProperties -> Fill and at the start there is option to set the expression for fill color.
You are using the wrong expression the expression should be ,
= IIF(Sum(Fields!ID.Value) < 15,"Red","Transparent")
You can change the Transparent to whatever color you want.Take a look here on how to use expressions.

This shows how you could add a colour range if necessary by using the Color property to set the font colour.
=iif(Sum(Fields!ID.Value) < 15,"Red",iif(Sum(Fields!ID.Value)>50,"Blue","Black"))
To Change the background colour instead you would use the Background colour property.
=iif(Sum(Fields!ID.Value) < 15,"Red", "No Color")
Note that SSRS 2008 "Transaparent" is replaced by "No Color". Whilst transaparent works it gives rise to this warning message.
[rsInvalidColor] The value of the BackgroundColor property for the textbox ‘textbox22’ is “Transparent”, which is not a valid BackgroundColor.
As an alternative to these use "#FFFFFF" instead of Transaparent or No Color

Related

Change backcolor of DataGridViewButtonCell

I've created a DataGridViewButtonCell in this way:
For i As Integer = 0 To dgvHouse.Rows.Count - 1
dgvHouse.Rows(i).Cells(3) = New DataGridViewButtonCell()
End For
Now I want to change backcolor of these DataGridViewButtonCell.
I've tried to do this in the following way:
dgvHouse.Rows(i).Cells(3).Style.BackColor = Color.Red
But this change backcolor of cell not of the DataGridViewButtonCell
How can I do that? How can I access to a specific DataGridViewButtonCell
"But this change backcolor of cell not of the DataGridViewButtonCell". That's actually a nonsensical statement. "the cell" is a DataGridViewButtonCell and that code changes the background colour of it. The problem is that you can't see the background of the cell because it has a rendering of a button over it. That rendering is based on system settings. You'll find that you can see the background colour if you change the FlatStyle property to certain values. If that result isn't enough, you'll need to create a custom column with custom cells that render the way you want.
Note that, if you want something to affect every cell in the column, make the change on the column, via the DefaultCellStyle property.

Can't get DataGridView cell BackColor property

I'm trying to retrieve the current color of a DataGridView cell while iterating through the Grid. I am explicitly setting the BackColor for both RowsDefaultCellStyle and AlternatingRowsDefaultCellStyle in the Form Load event.
I'm trying to get the cell BackColor per this question, however, at run time, while iterating through cells in a row, in the Immediate Window this: ?dgvemployees.Rows(rowIndex).Cells(i + 1).Style.BackColor.ToString returns "Color [Empty]" every time - even if I change the indexes to get another cell that I know has the default color set.
Am I missing something or not doing something right?
This page on the Cell Style says:
The DataGridView control displays its cells using the styles indicated
by the cell InheritedStyle property, which inherits styles from other
properties of type DataGridViewCellStyle. The styles specified through
the Style property override the styles specified through all other
cell-style properties, but do not necessarily indicate all the styles
that contribute to the cell's appearance.
Basically, you are trying to access the specific cell back color when it hasn't been set. Even though you have set the back color of the rows, it can be overridden at the cell level.
Thankfully, Microsoft has given us a nice way to find the inherited style of the cell, which will get you the grid-level setting for these cells (unless something further down the chain has overridden that).
?dgvemployees.Rows(1).Cells(2).InheritedStyle.BackColor.ToString()
If I had something else that could override this value and cause problems, then I think I'd be left doing a modulus on the row count to see if it was an alternating row or not.

SSRS Color literal not working in variable expression

I'm trying to create a custom template report so that reports inheriting from it will use corporate standards for color and font. I want to create report variables for these, so that the same color can be employed in different parts of the report.
For instance, in the report header properties, I set the RGB values for the BackgroundColor property and, when I save my changes, I see a literal value in the property text box. If I then open the dropdown for the property again, and click the "Expression..." link, I see a numeric literal - in this case, #006a4d, which is a dark green. (I'm somewhat new to SSRS expressions, but apparently expressions that represent numeric constants don't require the "=" sign at the beginning.)
This tells me the constant representing the RGB combination that I want. Now, I go into the Variables tab of the Report Properties dialog and create a variable called "BckndClr" with the same hex constant as its value.
If I then go back to the BackgroundColor property and set it to the expression:
=Variables!BckndClr.Value
and save it, I find that, instead of continuing to to be dark green, the report header's background color in the Design tab has changed to the Auto default (white) color.
If The Visual Studio properties dialog displays a value for a literal color expression, why can't I use that same value in a user-defined variable and set the property expression to that variable?
What you are calling the "literal color expression" (#006a4d) is the hex value of the color. You can use this website to convert your RGB values to hex. Not sure what version of SSRS you are using. I duplicated your steps in with SQL Server 2012 SP1 using SQL Server Data Tools for VS 2012.
Created a variable in the report properties. Called it test. Pasted the hex value directly into the value box without clicking the expression button.
Went to the header properties, clicked on fill, and then clicked on the expression button next to the fill color. Enter =Variables!test.Value as the expression. Click OK.
Preview report. And verify the color of the header is dark green.

Checkboxes in Rdlc Report

I am creating rdlc report and i have issue that i got some bool type object fields and now i have to show checkboxes. but there is nothing i found for this solution to show checkboxes in table.
Is there anyone who know that how i can implement that thing?
Maybe you can put image there, depend on true or false, just display different pic. LOL
If checkbox is true I set Chr(254) else show unchecked checkbox using Chr(168).
Chr(254): This is decimal value for Wingdings character 254 its shows like checked check box image.
Chr(168): This is decimal value for Wingdings character 168 its shows like rectangle box like unchecked check box image.
I had a requirement that the checkboxes have a background color. I liked the simplicity of a text-based rather than image-based approach, so I used a variation of the popular Wingdings-font method: I used a small, square textbox with a thin border and the specified background color, set it to use a bold, sans-serif font, and used this expression for the text value:
=IIf(Fields!SomeBool.Value, "X", "")
If you still want a checkmark rather than an X, you can use Wingdings 2 font and this expression:
=IIf(Fields!SomeBool.Value, Chr(80), "")
In either case, you may have to adjust the font size and/or box size to keep the result square; my first take was taller than wide because it expanded vertically to accommodate the font.
Or you can set the textbox placeholder to render tags as html and then put this html in: Or you can set the Placeholder expression to support HTML and then set up the following html code:
<font face="Wingdings 2" color="green">#Html.Raw(((char)0x51).ToString())</font>
You should put in the character of the wingdings that you want.
This way, only part of the text can be wingdings.
Wingdings 2
Finally I got solution
here is the link download the project and run it.
http://uploading.com/files/2mmf34m8/Nestle%2BNew.rar/
i have developed class and then used list to set bool variable true/false. while on other hand i used image control in rdlc report To set image.
You just need to set image path which are already in image folder.
Cheers.

ms-access: check if font color is white

in conditional formatting what would be the expression i would use to check whether a DIFFERENT textbox's font color is set to white?
With VBA, you can check whether a control's ForeColor property is white (vbWhite = 16777215).
If Me!SomeControl.Properties("ForeColor") = 16777215 Then
However, I'm lost trying to figure out how to apply that approach in conditional formatting.