conditional color coding of a textbox in SSRS Report based on date range - ssrs-2008

I have below columns in my report body and I need to fill background color in a ProviderNextContactDate textbox based on below condition
ProviderContactDate ProviderNextContactDate
2/3/2022 8/3/2022
1/6/2022 7/6/2022
11/18/2022 5/18/2022
..
if ProviderNextContactDate is past due then Red
if ProviderNextContactDate is within 30 days then yellow
otherwise transparent

Assuming past due means past on or earlier than today and your colums are Date or DateTime data types, then just set the backgroundcolor property of the textbox to an expression something like this...
=SWITCH(
Fields!ProviderNextContactDate.Value >=Today(), "Red",
DateDiff("d", Fields!ProviderNextContactDate.Value, Today()) <=30, "Yellow",
True, Nothing
)
The final 'True' acts like an else. 'Nothing' is the default backgroundcolor for textboxes which is effectively transparent.
You may need to adjust the numbers of days or the >= and <= depnding on your needs. For example, DateDiff returns the number of boundaries crossed, in this case the number of days (denoted by the "d").

Related

Calculated field affected the Grand Total in Tableau

Used a calculated field by using the window_max and window_min functions:
IF
([eCPM]) = WINDOW_MAX(([eCPM]))
THEN "Least efficient" ////Red
ELSEIF [eCPM] = WINDOW_MIN(([eCPM]))
THEN "Most efficient CPM" ///Green
ELSE "Neither" ///Gray
END
But this also affected my Grand Total. I don't want any coloring in totals. How to handle this? (Solved)
Since my calculation is based upon eCPM, can only this column be highlighted as green rather entire row, without highlighting media cost and visits green as well?
Since my calculation is based upon eCPM, can only this column be highlighted as green rather entire row, without highlighting media cost and visits green as well?
You just need to "wrap" you if statement with another one in order to handle the grand total using size which returns the number of rows in the partition.
Using the superstore you can create a calculated field like this:
// Handle Grand Total
IF SIZE() = 1 THEN "Neutral"
// Handle all other "rows"
ELSE
IF sum([Sales]) = WINDOW_MAX(sum([Sales]))
THEN "Green"
ELSEIF sum([Sales]) = WINDOW_MIN(sum([Sales]))
THEN "Red"
ELSE "Neutral"
END
END
The result could look like this:

SSRS: Custom colors for the Category axis of a stacked bar chart

I have a stacked bar chart that only ever has 5 categories(but the value of the categories change from year to year, it is a sliding 5 year window).
I have successful customised the bars to the colors I want.
But now I wish to make the label of each Category the same color as the customised bar color.
Is there a way to do this?
You can use custom code for this.
In Report Properties | Code, you can paste in the following 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
This will give you the option of the pastel colour palette. If you want other colours, simply replace the hex colour codes with values of your choice.
To use this, simply use the following expression:
=Code.GetColour(Fields!Thingy.Value)
Use this on your series and your label fill expressions. This will ensure that the same colour appears for both. If you have multiple graphs with the same values in, this will also ensure that the same data series across multiple graphs always have the same colour.

Need to count a running value percentage top 80 percentile number of rows

I have a running value expression that color codes (Yellow) when it reaches 80%. The remaining 20% are then without color. I need to count the number of rows that comprise that 80%.
Here is the expression that's placed in the Background Color properties:
=IIF(RunningValue(Sum(CDbl(Fields!qtr_total.Value)), Sum, "Data8020") <
(Sum(Fields!qtr_totalValue.Value, "Data8020") * .8), "Yellow", "Transparent")
I just need to count the number of rows that are marked in yellow.
Add a column with the following expression:
=IIF(RunningValue(Sum(CDbl(Fields!qtr_total.Value)), Sum, "Data8020") <
(Sum(Fields!qtr_totalValue.Value, "Data8020") * .8), 1, 0)
and then sum this column to get to the count value. You can hide this column so that it wont mess the looks of your report.

Regarding Jasper report bar chart

I'm using jasper ireport 4.0.1 for developing. And I need to realize a bar graph being shown according to the imported 2 parameter one is for the used and the other is the total value. I want the left part of this bar represented in red color and the length will be changed according to the proportion of the used value out of the total also the used value need to be shown on this part of bar and the rest of the bar in green colour with the length regarding the total minus by the used value. How can I realize that, any help will be appreciated!
Let say the total value is 45
If the used value is 24 then the bar graph will show as follow
If the used value is 44 then the bar graph will looks like this
Regards,
You can achieve that by defining 2 parameters:
max: maximum value
proportion: value when it should switch between blue and green.
Then you add a stacked bar chart with 3 series:
Series1: series expression: "RED", category expression $F{<field>}, value expression $F{<value>}
Series2: series expression: "BLUE", category expression $F{<field>}, value expression $F{<value>} < $P{proportion} ? $P{max} - $F{<value>} : 0
Series3: series expression: "GREEN", category expression $F{<field>}, value expression $F{<value>} >= $P{proportion} ? $P{max} - $F{<value>} : 0

Indicators in SSRS

I have a column in SSRS report. The value is "True" or "False" or "Yes" or "No" or "1" or "0"
Instead of showing that in that column, I would like to use indicator.
I placed indicator in that column but need to set start and end property. How do I go about doing it so I can show green checkmark when it's "True", "Yes", or '1" and red otherwise?
I am trying =IFF(Fields!Column_name.Value = "True", "Red", "Green") for the Start value for Green Check mark...but obviously I am wrong...
any help?
Well maybe its just a typo in your question but a couple things stand out
the function is IIF, not IFF
The True result should come first after the condition
I've never used the indicators before, but looking briefly at them, it looks like you can define ranges that are acceptable (green), unacceptable(red), or in the middle (yellow).
Start and End should probably be numeric values, "Green" and "Red" don't seem like valid values.
Try binding the indicator value expression to something like this.
=IIF(Fields!ColumnName.Value = "True" OrElse
Fields!ColumnName.Value = "Yes" OrElse
Fields!ColumnName.Value = "1", 100, 0)
Go to the Indicators properties > Values And States and put the Check's Start & End Value to 1. And the X put it's Start & End Value to 0.
Then write your expression like this:
=iif(First(Fields!YourField.Value, "YourDataSet")=True,1,0)
That should give you a Check if checked or an X if not.