My requirement - If condition satisfy then ID column should be blue else black
Blue color = type="NY" and isact=true and eqe=true
Blue color = type="CAL" and isact=true
black color = type="NY" and isact=false and eqe=false
black color = type="NY" and isact=false and eqe=true
black color = type="NY" and isact=true and eqe=false
black color = type="CAL" and isact=false
=IIf(Fields!IsAct.Value = True,
IIf(Fields!EQE.Value = True,
IIf(Fields!Type.Value = "NY", "Blue","Black"),"Black"), "Black")
or
IIf(Fields!IsAct.Value = False,
IIf(Fields!Type.Value = "CAL", "Black","Blue"), "Black")
I have this logic in font ID column. If I run above individually then its working but if i combine its not working. Any help is really appreciate.
This is looking very complex and I think there's a cleaner way to do this with a SWITCH statement. I believe the following expression should work well.
=SWITCH(
Fields!Type.Value = "NY" AND Fields!IsAct.Value AND Fields!EQE.Value, "Blue",
Fields!Type.Value = "CAL" AND Fields!IsAct.Value, "Blue",
Fields!Type.Value = "CAL" AND NOT Fields!IsAct.Value, "Black",
Fields!Type.Value = "NY" AND NOT Fields!IsAct.Value AND NOT Fields!EQE.Value, "Black",
Fields!Type.Value = "NY" AND NOT Fields!IsAct.Value AND Fields!EQE.Value, "Black",
Fields!Type.Value = "NY" AND Fields!IsAct.Value AND NOT Fields!EQE.Value, "Black",
True, "Black")
So I think that expression handles all of the cases you provided, but if I'm reading correctly, you really only have 2 conditions that set the color to blue, otherwise it is black. So the following should work just as well.
= IIF((Fields!Type.Value = "NY" AND Fields!IsAct.Value AND Fields!EQE.Value)
OR (Fields!Type.Value = "CAL" AND Fields!IsAct.Value), "Blue", "Black")
Related
I have a Report where I want to change the background color of the column(sales) based on the Continent column values. Below is the continent column values.
I tried the following expression under Sales column( background color),
=IIF(Fields!column.Value ="4th Quarter",
SWITCH (
Fields!continents.Value ="Asia", "Green",
Fields!continents.Value = "N America","LIMEGREEN",
Fields!continents.Value ="S America","Yellow",
Fields!continents.Value = "Europe", "Red"
)
, "Dummy Value")
When I preview the report, I can see only Green color for all the rows. I know Switch function in SSRS will return the first expression that it finds true.
I also tried by using only IIF condition, still same issue. Is there a way this can be achieved?
Have you tried something like the following?
=IIF((Fields!column.Value ="4th Quarter") AND (Fields!continents.Value ="Asia"),"Green",
IIF((Fields!column.Value ="4th Quarter") AND (Fields!continents.Value = "N America"),"LIMEGREEN",
IIF((Fields!column.Value ="4th Quarter") AND (Fields!continents.Value ="S America"),"Yellow",
IIF((Fields!column.Value ="4th Quarter") AND (Fields!continents.Value = "Europe"), "Red",
"Dummy Value"))))
I'm trying to get
<input type="color" class="color1" id="color2"></div>
give an output of the chosen color, here:
let clothColors = [OutputNeedsToBeHere]
Currently, I have to Manually change the colors myself, by changing and adding color values
["Color","Color","Color"]
etc. I'm making a Tearing Cloth project for school and I want to make it have as much Customization as Possible.
currently this function changes the color via a Button accessing it via
onclick="colorChange()"
function colorChange() {
cc += 1
pattern = false
if (cc >= clothColors.length) {cc = 0}
}
Now how would I get cc to become to output of the Color Input, so that I can simply choose a color on the
Input type="color"
and then click Ok and force it to change the color of the cloth manually to EXACTLY what I chose.
So Far I've tried making a Color-Wheel, and I guess my chrome version doesnt support them, or my Codepen Project is such a mess that it wont correctly activate, I also tried making an input text box that would change the color based on what you typed, (a Hex, RGBA, or Color). None of those worked, I did ask questions in a similar fashion to the one I'm typing right now, but those ones never obtained Full proof answers that successfully helped my issue.
[codepen][1] My full Codepen Project
<button onclick="colorChange()">BaseColors</button><input type="color"
class="color1" id="color2"></div>
Partial Needed bits of Javascript:
cloth:
function randint(min, max) {
return Math.floor(Math.random() * max) + min
}
let accuracy = 10
let gravity = 1000
let wind = 0
let cWind = 0
let clothY = 40
let clothX = 120
let spacing = 4
let tearDist = 60
let friction = 0.99
let bounce = 0.5
let noTop = false
let thickness = 1
let clothColors = ["red", "orange", "Gold", "yellow", "lime", "green",
"blue", "purple", "black", "grey", "darkgrey", "silver", "lightgrey",
"white"]
let cc = 0
let pattern = false
Functions:
function colorChange() {
cc += 1
pattern = false
if (cc >= clothColors.length) {cc = 0}
}
In the result I can Change the Color in a button by running the Length of the Colors written in
let clothColors:
and they are applied to the Moving cloth canvas. Unfortunately the Results I WANT are for the Colors Chosen in the input to Change the Color of the Canvas, See my link to the full project below if you wish to view the full code.
https://codepen.io/SkylerSpark/pen/ELwmoa
This works
https://codepen.io/anon/pen/ebXJaV
<button onclick="colorChange()">BaseColors</button>
<input onchange="colorChange()" type="color" class="color1" id="color2"></div>
function colorChange() {
var color = document.getElementById("color2").value;
if (clothColors.indexOf(color) ==-1) {
console.log("New color",color,clothColors)
cc=clothColors.length-1; // prepare cc to be at end
clothColors.push(color); // add new color at end
}
cc += 1; // business as usual
pattern = false
if (cc >= clothColors.length) {cc = 0}
}
I am creating a SSRS report and I have column named Priority and I want to change background color of that particular box based on the value.
This is what I have tried
=SWITCH(Fields!Priority.Value = Critical, "Red", Fields!Priority.Value = High, "Green", Fields!Priority.Value = Average, "Yellow", Fields!Priority.Value = Low, "Blue")
Error:
The BackgroundColor expression for the text box ‘Priority1’ contains an error: [BC30451] Name 'Critical' is not declared.
Thank you
The values on the right side of your equal signs need to be in double quotes.
=SWITCH(Fields!Priority.Value = "Critical", "Red", Fields!Priority.Value = "High", "Green", Fields!Priority.Value = "Average", "Yellow", Fields!Priority.Value = "Low", "Blue")
EDIT: Just to add a little description in case it's not clear: you need those double quotes since you're comparing to those strings. Bare words in expressions are assumed to be keywords, so when it gets to the word Critical and can't find any keyword associated with that, it doesn't know what to do. If you were comparing numbers, you would not need the quotes, but since you are dealing with strings in this case, you do.
I have a requirement to show different text color when one field matches with another three different fields.
I have written below expression,
=IIF(
Fields!OrderBlockLetter.Value = Fields!InstitutionBlockLetter.Value, "Green",
or Fields!OrderBlockLetter.Value = Fields!DegreeBlockLetter.Value, "Orange",
or Fields!OrderBlockLetter.Value = Fields!AwardBlockLetter.Value, "Blue", "No Color")
But its not working. When saving this code it gives error.
I am using SSRS report builder.
You can't use IIF with OR like that. IIF just returns a value if the expression is true and another if it's false. You can nest IIFs to get the desired results but using SWITCH is much simpler. Try this... (not tested but should be close enough)
=SWITCH
(
Fields!OrderBlockLetter.Value = Fields!InstitutionBlockLetter.Value, "Green",
Fields!OrderBlockLetter.Value = Fields!DegreeBlockLetter.Value, "Orange",
Fields!OrderBlockLetter.Value = Fields!AwardBlockLetter.Value, "Blue",
True, "Black"
)
As switch returns on the first true expression, if all the others fail, the final expression is always True so the "Black" will be returned.
EDIT: Actually, "No Color" is not a valid font. You either need to pick black (the default color), or white (to give the appreance of there not being text there)
SO Post
Current I've got 5 bars in my RS chart - in the future there might be 7 bars or 17 bars or 27 bars!
With a couple of bars I can have an expression like this:
=iif(Fields!Market.Value = "Spain"
,"Gold"
,iif (Fields!Market.Value = "Denmark"
, "Gray"
, iif(Fields!Market.Value = "Italy"
, "Blue"
, "Purple"
)
)
)
If I can't predict how many countries will be included + I'd rather not have to hard code in "Green", "Red" etc how do I change the expression?
I've tried this but it is erroring:
=Switch(Mod(Fields!Rank.Value/CDbl(2))=CDbl(0), "Gold",
Mod(Fields!Rank.Value/CDbl(3))=CDbl(0), "Gray",
Mod(Fields!Rank.Value/CDbl(2))>CDbl(0) "Blue")
Above is the totally incorrect syntax: This works:
=Switch(CDbl(Fields!Rank.Value Mod 2)=CDbl(0), "Gold",
CDbl(Fields!Rank.Value Mod 3)=CDbl(0), "Gray",
CDbl(Fields!Rank.Value Mod 2)>CDbl(0), "Blue")
Ok - the above runs (not sure how!) but the below is based on help from Dominic Goulet and is really easy to follow and nice and expandable to more colours; this is the solution for 5 colours:
=Switch(CDbl(Fields!Rank.Value Mod 5)=CDbl(0), "Gold",
CDbl(Fields!Rank.Value Mod 5)=CDbl(1), "Gray",
CDbl(Fields!Rank.Value Mod 5)=CDbl(2), "Green",
CDbl(Fields!Rank.Value Mod 5)=CDbl(3), "Red",
CDbl(Fields!Rank.Value Mod 5)=CDbl(4), "Pink")
First of all, instead of using many "IIF"s, you should use "Switch", it's leaner that way.
Switch(Fields!Market.Value = "Spain", "Gold",
Fields!Market.Value = "Denmark", "Gray",
Fields!Market.Value = "Italy", "Blue")
Now if you want a color per coutry, you should defenitely store that in your database and pull it out when you need it. That way, a country will always have the same color on every report you have.
It would be better to create a function. For that, go to Report Properties, choose code and type this example :
Public Function Color(ByVal Index as Integer) as String
Select Case Index
Case = 1
return "#a6cee3"
Case = 2
return "#1f78b4"
Case = 3
return "#b2df8a"
Case = 4
return "#33a02c"
Case = 5
return "#fb9a99"
Case = 6
return "#e31a1c"
Case = 7
return "#fdbf6f"
Case = 8
return "#ff7f00"
Case = 9
return "#cab2d6"
Case = 10
return "#6a3d9a"
End Select
End Function
On the Fill option from "Series Properties->Pick color-> Color choose fx
put this code
=Code.Color(rownumber(nothing))
Each bar will have a color.
For the HEX colors I took from the website : http://colorbrewer2.org/#type=qualitative&scheme=Paired&n=10
It shows the best colors that match with each other, so you don't need to think of that. And you can add as many colors as you want