Using SWITCH statement in reporting services for a date field - visual-studio-2005

I am trying to get this code to work in reporting services 2003:
=switch(
DateDiff("d", fields!WARRANTY_EXP!value,now()) > 765, "White",
DateDiff("d", fields!WARRANTY_EXP!value,now()) > 365, "Yellow",
DateDiff("d", fields!WARRANTY_EXP!value,now()) > 0, "Red",
DateDiff("d", fields!WARRANTY_EXP!value,now()) < 0, "Gray"
)
I'm trying to code a field so that if the date field is in the past it changes the background colour to grey, if it's going to be in the next year then red, and in the next 1-2 years yellow. Everything else white.
I've tried rearranging it but the coding must be wrong somewhere as greater than 2 years is grey, dates in the past are yellow and next year is red :-S
Many thanks,
Pierce

I think you may just have your greater than and less than signs the wrong way round, or your now() and field expression the wrong way round.
Instead of
DateDiff("d", fields!WARRANTY_EXP!value,now()) > 0, "Red",
Try
DateDiff("d",now(), fields!WARRANTY_EXP!value) > 0, "Red",
#
An Example from the online help:-
Test the value of the ImportantDate field and return "Red" if it is more than a week old, and "Blue" otherwise. This expression can be used to control the Color property of a text box in a report item:
Copy
=IIF(DateDiff("d",Fields!ImportantDate.Value, Now())>7,"Red","Blue")

Related

Change color of only one data point in gnuplot

I'm doing a gif in gnuplot, and I have my data separated in blocks. I need the points to be white except from just the first row of every data block, which would be an orange point.
Currently my code is:
#...
do for [i=0:int(STATS_blocks-1)]{
plot "positions.txt" index i pt 7 ps 0.5 lc 'white' title "t = ".((i+1)*200)." Myr"
}
As you can see, this plots every data point white, including the first row.
Edited to show variable pointsize also
If I understand your data format correctly:
set linetype 11 lc "orange"
set linetype 12 lc "white"
set style data points
do for [i=0:N] {
plot "positions.txt" index i using 1:2:(column(0)>0 ? 0.5 : 2.0):(column(0)>0 ? 12 : 11) pt 7 ps variable lc variable
}
Variable color (if used) is always taken from the very last using column. Other variable properties work back from there.

How to change the color of a label in gnuplot [duplicate]

Very simple stuff. I want a function, say function f, to be plotted with a particular color. I also want a piece of label saying "function f color" which is also displayed in that color.
I am trying this so far:
set style line 1 lw 3 lc 1
set label "AC" at 0, 70 textcolor 1
but apparently the "lc" and "textcolor" follows different specs, and it complains:
"trolo4.pl", line 8: colorspec option not recognized
any help would be great!
Try this instead:
set label "AC" at 0, 70 textcolor linetype 1
or
set label "AC" at 0, 70 textcolor linespec 1
Read the manual in gnuplot> help label to learn more.
The answer by #holygeek works fine. Coming from python, I find that it is often nice to be a little more explicit.
set style line 1 lw 1 lc rgb "red"
set label "AC" at 0, 70 tc rgb "red"
Note that the set of color names recognized by your gnuplot is system dependent (see show colornames for a complete list). To achieve complete system independence, you can use the #RRGGBB version. e.g. red is '#ff0000, green is #00ff00 and blue is #0000ff. of course, you can make up all sorts of interesting colors (again, see show colornames for a list of pre-defined colors and their equivalent #.....)
for more info, also see help colorspec

pentaho CDE conditional formatting of bubble chart

I have used CCC Heat Grid in CDE to create a bubble chart with bubbles of different colors. My data set has only 6 values: (1, 1.1, 2, 2.1, 3, 3.1). I have sizeRole property to "value" so that the size of the bubble varies based on the magnitude of these six values. Alternative, I could have set colorRole property to "value". I have set three colors: green (1), yellow (2) and red (3).
Now, what I want to have 1 as green, 2 as yellow and 3 as red; and biggest constant size for 1.1, 2.1 and 3.1. The values 1.1, 2.1 and 3.1 represent alarms in my data set, so I want them to be of biggest size bubble or some other differentiating visual element.
I tried the following in pre-execution but no luck
function changeBubbles(){
var cccOptions = this.chartDefinition;
// For changing extension points, a little more work is required:
var eps = Dashboards.propertiesArrayToObject(cccOptions.extensionPoints);
// add extension points:
eps.bar_shape = function getShape(){
var val = this.scene.vars.value.value;
if(val == 1.1 || val == 2.1 || val == 3.1){
return 'cross';
}
else {}
};
// Serialize back eps into cccOptions
cccOptions.extensionPoints = Dashboards.objectToPropertiesArray(eps);
}
How can we achieve this?
I hope the answer is still relevant, given that this is a late response.
To use bubbles you should have useShapes: true.
You can set a different constant shape by using the shape option. For example, shape: "cross".
To have the bubble size be constant, you should set the "sizeRole" to null: sizeRole: null. Bubbles will take all of the available "cell" size.
Then, the "value" column should be picked up by the "colorRole", but to be explicit, specify: colorRole: "value".
By default, because the color role will be bound to a continuous dimension ("value"), the color scale will be continuous as well.
To make it a discrete scale, change the "value" dimension to be discrete:
dimensions: {
"value": {isDiscrete: true}
}
Finally, to ensure that the colors are mapped to the desired values, specify the "colorMap" option:
colorMap: {
"1": "green",
"2": "yellow",
"3": "red"
}
That's it. I hope this just works :-)

Category colors in SSRS chart

I have a bar chart in SSRS that has one category group and no series groups. What I would like to know is if there is any way I can have each category show up as a different color, rather than all of them being a single color like SSRS wants to do?
The only way I know of to do this is to hard code the colors for each category in the Values' Properties -> Fill tab -> Color expression:
=IIF(Fields!DISPUTE_TYPE.Value = "Duplicate", "Red",
IIF(Fields!DISPUTE_TYPE.Value = "Eligibility", "Orange",
IIF(Fields!DISPUTE_TYPE.Value = "Corrected billing", "Green",
IIF(Fields!DISPUTE_TYPE.Value = "Additional information - Records", "Blue", "Yellow"))))
The downside is that you have to account for all values else they'll use the last "default" value (yellow in this code).
You could number each type in your query and use that number in a formula to create colors.

Changing font color when comparing fields in Report Builder 3.0

Report Builder 3.0
I have 2 columns - one is est hours - one is act hours
I want to change the hours in the act to "red" when it is higher than the estimate hours
I have tried the following
IIF(Fields!AcutalHours.Value > Fields!Estimate_Hours.Value "Red"
and I have tried the following
=Switch(Fields!Estimate_Hours.Value < Fields!AcutalHours.Value, "Black"),
=Switch(Fields!AcutalHours.Value > Fields!Estimate_Hours.Value, " Red ")
I am using the font expression
Are the fields definitely Numeric? Try converting them to Int to ensure it's comparing them as numbers.:
=Iif(CInt(Fields!ActualHours.Value) > CInt(Fields!Estimate_Hours.Value), "Red", "Black")
You can add a new calculated field to your Dataset in ReportBuilder with a formula like this:
=IIF(InStr(Fields!Original.Value,Fields!Updated.Value)>0, "White","Red")
Once that is done, Select the properties of the field that needs to be formatted, select fill, formula and set the expression for the BackgroundColor to
=Fields!MyCustomDiffField.Value
I use this method of formatting in Report Builder 3.0

Resources