SSRS Switch function for conditional color - reporting-services

In my SSRS report i have a parameter "Year". I have only 3 year ( 2018,2019,2020). When the user select the 2020 or 2019 the color of the BAR for the selecting year changes automatically "Lime" but for the selection of 2018 the color remains "Silver"
= Switch(
Fields!columnName.Value="Fluctuation Rate 2017", "Silver",
Fields!columnName.Value="Fluctuation Rate 2020", "Lime",
Fields!columnName.Value="Fluctuation Rate 2020 (Estimated)", "Yellow")
Bar chart colors are dynamically changes so current year bar is color lime

Related

Power BI custom theme .json - multiple series customization

I've been tinkering with .json file to create my own custom theme, however I am stuck on multiple choice setting. Example:
Area chart -> Format -> Data labels - > here I can customize the general setting for data labels, but what I would like to set up, is the "CUSTOMIZE SERIES" for each of the series. That is, I would like to have black text label color for the first serie, yellow for the second etc.
Below is the image from power bi for the category I am trying to customize:
Customize series in Power BI
Code for these labels:
"labels": [{
"show": true,
"color": {
"solid": {
"color": "#333333"
}
},
"labelPosition": "Under",
"fontSize": 14,
"fontFamily": "Arial",
"labelDensity": 30,
"showAll": true,
"enableBackground": true,
"backgroundTransparency": 70
What this .json code achieves, is that it sets up only the general settings for all the series. That is all series will have font size 14, font Arial, background transparency 70% etc. I would like to somehow index these series, so when this .json theme gets imported into power bi the first serie would have the customized settings that I've set up, second the same etc. E.g.:
"labelPosition": "Under",
"fontSize": 14,
"fontFamily": "Arial",
"labelDensity": 30,
"showAll": true,
"enableBackground": true,
Above are the general settings for all of the series, below would be the customized series
1. serie --->>>
"backgroundTransparency": 70
2. serie ---->>>
"backgroundTransparency": 60
3. series etc..

Conditionally format certain cells of tablix

Using Visual Studio 2017 (SSDT), I have a tablix where I would like to use an expression to set the background color/fill. I would like the cells to fill gray where the:
2019 Metal is Silver and 2020 Metal is Bronze, or
2019 Metal is Gold and 2020 Metal is Bronze, or
2019 Metal is Gold and 2020 Metal is Silver.
Visually, like this:
The data set populating the tablix is:
(I added custom "Is Null" code to display zeros instead.)
I've been trying IIF statement logic but have been unable to get my desired results.
The design of the tablix is:
I'm trying to set the Fill BackgroundColor on the textbox here with an expression:
...using something like:
=IIF(
Fields!METAL_YEAR_2020.Value="Bronze" AND
(Fields!METAL_YEAR_2019.Value = "Silver" OR Fields!METAL_YEAR_2019.Value = "Gold")
, "Gray"
, "Transparent"
)
If I leave out the OR condition I can fill one intended cell, but I don't know how to account for the three cells.
So, this code below sets one cell but can I nest or SWITCH to set the three cells I want?
= IIF(
(
(Fields!METAL_YEAR_2019.Value = "Silver" and Fields!METAL_YEAR_2020.Value = "Bronze")
OR (Fields!METAL_YEAR_2019.Value = "Gold" and Fields!METAL_YEAR_2020.Value = "Bronze")
OR (Fields!METAL_YEAR_2019.Value = "Gold" and Fields!METAL_YEAR_2020.Value = "Silver")
)
, "Gray", "White")
since there is no data where you get the null values (not only the integer value is absent, but all values, you have to refer to the group value, which is in the textbox)
= iif(
(cstr(ReportItems!Metal_2019.Value) = "Silver" AND cstr(ReportItems!Metal_2020.Value) = "Bronze") OR
(cstr(ReportItems!Metal_2019.Value) = "Gold" AND (cstr(ReportItems!Metal_2020.Value) = "Silver" OR cstr(ReportItems!Metal_2020.Value) = "Bronze")),
"Gray","Transparent")
found at

Changing color of body report, depending on value in table

I have report in SQL Server 2008.
Report has a parameter, parameter values:
organization1
organization2
organization3
organization4
To display a list of parameter with values, I used "Available Values" "Get values from a query".
If value of organization1 parameter in "Value" column is greater than
20, then report body and background of tables should be in red color.
If selected parameter organization1 background of tables and report body should be in red color.
If selected parameter organization2 background of tables and report body should not be in red color.
If selected parameter organization3 background of tables and report body should be in red color.
If selected parameter organization4 background of tables and report body should not be in red color.
The expression below does not work for selected parameter.
=IIF(Fields!AVID.Value, "summ_work">20 and
First(Parameters!ReportParameter1.Value, "test")="Organization1","Red","Transparent")
How can I fix it?
You're going to need something like this for the BackGround expression in the report.
=Switch(Sum(Fields!value.Value, "DataSet1") > 20 And Parameters!Organization.Value = "Organization1", "Red",
Parameters!Organization.Value = "Organization1", "Red",
Parameters!Organization.Value = "Organization2", "White",
Parameters!Organization.Value = "Organization3", "Red",
Parameters!Organization.Value = "Organization4", "White",
True, "Yellow")
That last line of the Switch is a catch all that will turn the background Yellow. Do what you want with that, or remove it entirely if you don't think the situation will happen where someone passes a parameter value other than what you have in the list.
I went with White as the "should not be in red" color, change that to something else if you like.

SSRS 2008 Background colour based on values

I am trying to use this expression to change the background colour of a text box within SSRS 2008
=IIF(Fields!Score.Value <=12, "Green", IIF(Fields!Score.Value >=13, "Amber" , IIF(Fields!Score.Value >=19, "Red" ,"White")))
The result is 15 which should pull back an amber colour which it is not doing.
The thresholds for the score field are
High 19-24
Medium 13-18
Low < 12
Try to convert field value to INT, Might be expression considering this as string
=IIF(CInt(Fields!Score.Value) <=12, "Green", IIF(CInt(Fields!Score.Value) >=13, "Amber" , IIF(CInt(Fields!Score.Value) >=19, "Red" ,"White")))
Assuming 'Score' is an INT you just need to swap the tests for >= 13 and >=19 as follows:
=IIF(Fields!Score.Value <=12, "Green", IIF(Fields!Score.Value >=19, "Red" , IIF(Fields!Score.Value >=13, "Orange" ,"White")))
Also 'Amber' isn't a valid colour name so change that to something like 'Orange' too.

To handle the increment and decrement of a value in an expression and display the corresponding indicator SSRS reporting service

I have a table table of values displayed in SSRS .
The table has fields metricID , currentmonth , preciousMonth
Questions :-
1. I have to compare 2 values like current month and previous month
Fields.PreviousMonth.Value < Fields.CurrentMonth.Value
THEn Check if the metric id is metricID is 7 then increase in currentmonth should be displayed as up arrow with red colour else it should be downarrow with green colour.
For all other Metric ID's it should be "upp arrow with green colour" else "down arrow with red colour"
Does anybody have an idea on how to do this
To do this you will need to set up custom indicators and set an appropriate expression to set the indicator.
I have some simple data:
And a simple report with an indicator per row:
The indicator is set up as:
Where the expression is:
=Switch(Fields!MetricID.Value = 7 and Fields!CurrentMonth.Value - Fields!PreviousMonth.Value > 0, 1
, Fields!MetricID.Value = 7, 2
, Fields!MetricID.Value <> 7 and Fields!CurrentMonth.Value - Fields!PreviousMonth.Value > 0, 3
, true, 4)
So what I'm doing is assigning each row a specified state based on your business rules, and I've set appropriate icons for each of those states.
Report is working as required:
You could move the expression above into a calculated field in the Dataset if you needed to use it in multiple places in the report.