Two legend items for one series - reporting-services

I have a chart on which I'm using two colours for one series: red for values below a certain value and green for above.
Is there a way I could display two items in the legend for this series? So far I've tried using Iif in the legend's expression, but it returns only one value.

I suggest you add 2 calculated fields in your dataset one for below and one above. Here you can use 2 IIfstatements to separate the values in your chart.
Alternatively you should be able to add the field in question to the chart twice and add an expression as above to each one for above and below.
In either of these cases there will be 2 entries in the legend.
I hope I'm on the right track for you however I can't test this at the moment.

I just did this a little bit ago for a pie chart but not with colors. Do you have to have the colors be shown or could you set a custom array of colors up and reference that instead?
In my problem I had to list 'ranges' of percentages occurring. (Someone wanted things in a range to be counted instead of individual counts).
I created a dataset 'DataforPie':
Declare #temp table ( id int identity, name varchar(8), perc decimal(2,1))
insert into #temp values ( 'Brett', .9),( 'Brett', .5),( 'Brett', .4),( 'Brett', .3)
,( 'John', .1), ( 'John', .3),( 'John', .4),( 'John', .2)
,( 'Brian', .5), ( 'Brian', .6),( 'Brian', .5),( 'Brian', .3)
select *
from #temp
I then set up a pie chart with the 'values' being [count(perc)] and an expression for the 'grouping' and 'labeling' of a 'Category Group' defined as:
=Switch(
Fields!perc.Value >= 0.6, "Greater than 6",
Fields!perc.Value >= 0.3, "Greater than 3",
Fields!perc.Value >= 0, "Greater than 0"
)
Now with your issue since you want custom colors I think you may wish to define a palette expression to determine colors. There is a good example of this here, even if it is a previous version it should still be similar: http://www.cubido.at/blogs/Lists/Posts/Post.aspx?ID=1256

I was in a similar problem and I solved it using the following steps:
Add the mentioned value field in the series group section
Right click the added series group and select series group properties
Add an expression in the Label Field e.g =IIF(Fields!abc.Value<=10,"TenOrLess",...)
In the fill section select gradient and select "No Color" in Color and set an expression in the Secondary Color e.g. =IIF(Fields!abc.Value<=10,"Red",...)
Click on series and in its properties window under the CustomAttributes section set DrawSideBySide to False

Related

Google Sheets - Combine multiple IF Functions into one cell

I'm trying to produce a SKU in Google Sheets for a product using the values of three variants (Title, Colour and Size)
The product is 'Lightweight trainers' with colour variants of 'Red' and 'Blue', and the sizes range from 5 - 12.
Link to spreadsheet
https://docs.google.com/spreadsheets/d/1trq0X3MjR-n2THFnT8gYYlwKscnQavCeeZ8L-ifYaHw/edit?usp=sharing
Aim
I'm hoping to have a SKU that displays the product, the colour variant and the shoes size.
Example: LW-1-8 (Lightweight trainer, colour Red, size 8)
Product is Lightweight Trainers with a value of LW.
Colour variant 'Red' with a value of 1 and 'Blue' with a value of 2.
Shoe size variant = number ranging from 5 to 12.
Here's what I have so far, joining the colour and size variants.
=IFS(I2="Red",1,I2="Blue",2)&"-"& IFS(K2="5",5,K2="6",6,K2="7",7,K2="8",8,K2="9",9,K2="10",10,K2="11",11,K2="12",12)
However, I'm getting stuck in joining the data in column B with this function.
Any help with combining this data from multiple cells into one would be greatly appreciated.
TL;DR
=ARRAYFORMULA(IF(B2:B<>"", IFS(B2:B="Lightweight Trainers", "LW")&"-"&IFS(I2:I="Blue", 1, I2:I="Red", 2)&"-"&K2:K,))
Answer
What you want is basically:
<title>-<color number>-<shoe size>
To convert this to a function we can split it into each part and take it step by step:
Step 1: Title
For the first part -the title- we need to match the value with the shorthand. A simple list in an IFS is enough.
IFS(B2="Lightweight Trainers", "LW")
Obviously for now it only has a single value (Lightweight Trainers) but you could add more:
IFS(B2="Lightweight Trainers", "LW", B2="Heavyweight Trainers", "HW")
Step 2: color number
Similar to the previous step, it’s a mapping using ifs:
IFS(I2="Blue", "-1", I2="Red", "-2")
The dash is added so when adding everything it will only have it if
Step 3: shoe size
In this case we can simply get the value:
K2
Step 4: Adding everything together
We only need to add it with the dashes in between:
=IFS(B2="Lightweight Trainers", "LW")&"-"&IFS(I2="Blue", 1, I2="Red", 2)&"-"&K2
Step 5: Extending for the entire column automatically
We will use ARRAYFORMULA to add a single formula to the first cell and get it automatically extended to the entire column. We first add it to the formula we already have, and then extend the ranges to the entire column:
=ARRAYFORMULA(IFS(B2:B="Lightweight Trainers", "LW")&"-"&IFS(I2:I="Blue", 1, I2:I="Red", 2)&"-"&K2:K)
Remember to remove all the values in the column so array formula doesn’t override them (it would generate an error).
As you can see the formula generates errors for the rows that have no values. A good way of handling this case is to filter the rows without a title. In a single row would be:
=IF(B2<>"", [the entire formula],)
Notice the last comma.
So putting everything together and extending its range to the column, is:
=ARRAYFORMULA(IF(B2:B<>"", IFS(B2:B="Lightweight Trainers", "LW")&"-"&IFS(I2:I="Blue", 1, I2:I="Red", 2)&"-"&K2:K,))
Adding this to N2 should work.
Final notes
It seems that you use 150 when the size it’s not a whole number. If you want to keep that functionality you may use:
IF(K2-int(K2)=0, K2, 150)
On the last component and expand it the same way.
You may also want to prevent having two dashes when a value is missing (LW-5 instead of LW--5). To do so, I’d recommend adding it to each component instead of the formula that adds them together.
References
IFS (Docs Editors Help)
IF (Docs Editors Help)
ARRAYFORMULA (Docs Editors Help)
try in N2:
=IFS(I2="Red",1,I2="Blue",2)&"-"&
IFS(K2=5,5,K2=6,6,K2=7,7,K2=8,8,K2=9,9,K2=10,10,K2=11,11,K2=12,12)
or use:
=IF(I2="red", 1, IF(I2="blue", 2, )&IF((K5>=5)*(K5<=12), "-"&K5, )

Conditional format of cell with different data types in SSRS?

I am trying to add a fill color to a table that I created in SSRS. The data looks like the table as follows:
The task is whenever the value is over 7, then color the cell green, when the value is less than 7 then orange and if the value is below zero then the due time changes to a sentence as shown with ID 2 and is to be colored red.
I have achieved coloring the cells when greater than or less than 7 using the if statement on the Due(Mins) field value however, it fails to color the cell red when less than 0. I have used switch, instr functions, but haven't had any luck.
Can emphasize more. Appreciate the help.
Cheers,
Sid
=SWITCH(
Fields!Due.Value.ToString.Contains("OverDue"), "Red",
VAL(Fields!Due.Value) > 7, "Green",
True, "Orange"
)
Switch will stop when it hits the first expression that evaluates to True
So...
First we test if the value contains overdue and set red
Then we test if the value is greater than 7 and set the result to Green
The True at the end acts like an else

SSRS SUM color base on additional parameter

My report looks like in picture below: each row is a location, columns are dates, qty is a SUM.
In this example QTY would be 30, I would like to color it following logic:
If all parameters are the same and equal to some value apply color.
If all parameters are not the same apply color.
EDIT:
param is a part of Dataset
You should be able to use an appropriately scoped CountDistinct here in the Color or BackgroundColor expression as required. Something like:
=IIf(CountDistinct(Fields!param.Value, "MyGroup") > 1, "Red", "Green")
Where MyGroup is the Scope you want to look at; you might want to change it to the Scope of your DataSet or whatever. I've just assumed group based on your data.
In this expression, the highlight will be Red when there is more than one distinct param in Scope, otherwise Green.
Edit after comment
Where you want to group certain param items together, you could use a Calculated Field to group these together in your DataSet definition, then just use this as required in your report. The Calculated Field, let's call it paramColour, might look like:
=Switch(Fields!param.Value = "AA" or Fields!param.Value = "BB", "Orange"
, Fields!param.Value = "CC", "Green"
, true, "Red")
I used a Switch here to make it easier to add future values.
You can then use this directly to set properties, i.e. set BackgroundColor to this value, or just amend the expression above:
=IIf(CountDistinct(Fields!paramColour.Value, "MyGroup") > 1, "Red", "Green")
It's nice having a Calculated Field as you can define it once for the DataSet and use it in multiple places in the report.

Color chart bars depending on category group value

I have the following chart (ssrs 2008), it shows sales according to #FromDate and #ToDate parameters.
The data is correct.
The problem is that when it shows comparison between years (=more than one year for the same month on a chart), the color stays the same, as you can see in months 4, 5, 6, 7:
How can i change it?
I would appreciate your help
There are a few different web descriptions with overviews of controlling the bar colors in a chart, such as this at learn.microsoft.com or Change the series colors for a bar chart (Images are currently dead in this, limiting its helpfulness).
The key is finding the "Series Properties" dialog and the "Fill" section, where you can specify the fill color: Use an expression such as:
=IIF(YEAR(Fields!MyDateField.Value) mod 2 = 0, "#FF0000", "#00FF00")
To Add some more explanation to JamieFs answer. This is the steps that I followed:
Right click on the series Select "Series Properites..."
Go to Fill:
Press the Expression button(Fx) and type in your equation to calculate the colour:

Stripline Background colour based on data

I have a chart which measures volume (y-axis) against date (x-axis). I have an Event table, which stores meaningful events, which I'd like to display as a vertical stripline on the chart. When there's data there, the field E_Text will be populated.
I've tried various methods, and am currently trying to only display using a change to the background colour, as such ("#00ffffff" is no colour):
=iif(Fields!E_Text.Value="","#00ffffff","Orange")
However, this statement always returns true, despite the data always being there. Has anyone managed to get data-driven striplines working?
Are you certain you are capturing nulls? A blank is something. NULL and (blank) are two different things. In SSRS Null is captured with Isnothing(), putting a value inside the parentheses. I have never had tried data driven strip lines with this method but this in the past has been an issue. Also can you test your function with an easier test first? EG: Set a simple dataset up and set the background color up with a dataset we know to have a null and a positive value:
Create test dataset
declare #Person Table ( person varchar(8), orders int);
insert into #Person values ('Brett', 10),('Sean', null)
select * from #Person
Put a table from the toolbox in and populate it with the two columns.
Set the background property of the [orders] column cell to
=iif( isnothing(Fields!orders.value), "White", "Red")
I now see a white and a red, HOWEVER if I do this:
=iif( Fields!orders.value = "", "White", "Red")
I get always white.