Indicators in SSRS - tsql

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.

Related

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

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").

vscode if/else conditions in user defined snippet

Looking at the vscode documentation for user defined snippets, it would appear that using the regex transform, you can do if/else conditions.
However, I can't seem to find any examples of this and I'm struggling to understand the correct syntax based on the BNF alone.
Can someone explain the syntax for this?
For example,
Lets say I have a snippet like this:
"body": [
"let color = '${1|white,black|}';",
"let hex = '${???}';"
]
If color==white, I want hex to output #fff, otherwise if black #000.
This works:
"color conditional": {
"prefix": "_hex",
"body": [
"let color = '${1};",
"let hex = '${1/(white)|(black)|(red)/${1:+#fff}${2:+#000}${3:+#f00}/}';" //works
],
"description": "conditional color"
},
However, as soon as I try it with default placeholders and choices, like
"let color = '${1|white,black|}';", // does not work
Apparently, you cannot do snippet transforms on default placeholder values. See transforms on placeholder values issues
I used the simpler if transform style, so here:
${1/(white)|(black)|(red)/${1:+#fff}${2:+#000}${3:+#f00}
if there is a group 1 $[1} in this case white then replace that group 1 with #fff and if group 2 (black) replace with #000, etc.
You could make it just an if/else (white) or not pretty easily.
"let hex = '${1/(white)/${1:?#fff:#000}/}';" // any non-`white` entry will print `#000`.
${1:? => if group 1 (white) print #fff , else print #000
The vscode docs are not very helpful on these conditional replacements, if you have more questions on their syntax, let me know.

How to change background color for each two rows in SSRS in a group

How can I write the expression in order to change background color for each two rows in SSRS?
I need something like that:
I tried expression
=IIF(Fields!Type.Value="2016 Submitted" , "LightBlue",
IIF(Fields!Type.Value="2015 Submitted" , "LightBlue",
Nothing))
But because some months dont have values it looks like this:
If I try this expression I get below:
=IIF(RunningValue(Fields!Count.Value, CountDistinct, Nothing) MOD 2 = 1, "White", "PaleTurquoise")
Dance-Henry I tried your code
=IIF(RowNumber(Nothing) Mod 4 = 1 or RowNumber(Nothing) Mod 4 = 2, "Aqua","White")
and this is what i got:
You can select the row in design pane and press F4 to setup property BackgroundColor as =IIF(RowNumber(Nothing) Mod 4 = 1 or RowNumber(Nothing) Mod 4 = 2, "Aqua","White")
Captures are attached. Do it accordingly.
RESULT is something like this
After going thru the link https://blogs.msdn.microsoft.com/chrishays/2004/08/30/green-bar-matrix/
Tested and it works well for the Green Bar Effect for Matrix. I will show it step by step here as for later reference.
Step 1: Create the Matrix and add one more column under the innermost row grouping in your matrix. (ColorNameTextbox here)
Step 2: Select the textbox of ColorNameTextbox and press F4 to setup BackgroundColor property as =Value shown below.
Step 3: Select the textbox of Matrix cell and press F4 to setup BackgroundColor property as =ReportItems!ColorNameTextbox.Value shown below.
Step 4: Drag the inner grouping header (ColorNameTextbox) to be as narrow as possible.
Step 5: Preview Pane to check the result.
If you could add a hidden color_group column and populate it with a new number at each point you want to change the color (in your case 1,1,2,2,3,3,4,4) then you could use something like the following (which works for varying size groups):
IIF(RunningValue(Fields!color_group.Value, CountDistinct, Nothing) MOD 2 = 1, "White", "PaleTurquoise")
I had a similar problem where I could not come up with alternating rows because my data has Column Groups that were the RowNumber(Nothing) method to fail. Learning from all the other posts here this is how I resolved it in steps.
I added the following code into the report properties, that provides a function to get the row number, each time it is called. The function increments the row count each time it is called. >>Right click space around the report >> Properties >> Code. Alternatively go to Code Properties Window, when the report is selected.
Add the following lines:
Public Row_Sum As Decimal = 0
Public Function Lookup_Sum( ) As integer
Row_Sum = Row_Sum + 1
Return Row_Sum
End Function
I added a new column at the beginning of the rows called No. that would calculate and show the row number.Right click the first column >>Insert Column>>Inside Group-Left.
On the expression for the new report add this line of code. Also take a note of the name of the TextBox that will have the No. Value. It will be needed in the next step. In my case the TextBox is called TextBox6 (Properties Window). >>Right Click Cell>>Expression.
Add the code:
=Code.Lookup_Sum()
I highlighted the entire row and went to the Background property and added the following expression to compute the row number.
Add the code(TextBox6 is the name Textbox name noted above):
=IIF(VAL(ReportItems!Textbox6.Value) MOD 2, "LIGHTBLUE", "WHITE")

def negatives in JES

I am trying to show my picture as a negative, and I coded it, but it wont show the picture as a negative, did I do something wrong?
def negative(picButterfly2):
for px in getPixels(picButterfly1):
red=getRed(px)
green=getGreen(px)
blue=getBlue(px)
negColor=makeColor(255-red, 255-green, 255-blue)
setColor(px,negColor)
ALSO HOW DO I DRAW HORIZONTAL LINES? Thanks!
Try with correct variables names: you have picButterfly2 NOT EQUAL TO picButterfly1:
This works:
def negative(picButterfly1):
for px in getPixels(picButterfly1):
red=getRed(px)
green=getGreen(px)
blue=getBlue(px)
negColor=makeColor(255-red, 255-green, 255-blue)
setColor(px,negColor)
file = pickAFile()
picture = makePicture(file)
negative(picture)
show(picture)
Also look at:
This (for negating images).
This (for drawing lines) - or any of those.
Your variables "red", "blue", and "green" already have a function in it, change it to a single character or just a capital letter like "Red". I know this was posted in 2014 but I'll leave a comment for the future.

Comparing Turtle Color In Netlogo

I am trying to do something I imagine is relatively simply but for some reason I am having a heck of a time figuring it out and all my searches are turning up blank.
I want to query the color of a specific turtle and check if it matches another color. I want to do something like this:
if color targetTurtleNum = red [set target-confirmed true] ;
But I keep getting an error:
IF expected this input to be a command block, but got a true/false instead.
Any ideas?
Assuming targetTurtleNum is the "who" number of the turtle you are interested in, try:
if [ color ] of turtle targetTurtleNum = red [ set target-confirmed true ]
The error you are getting is because if expects two inputs: a boolean (the condition you want to check) and a command block (what to do if the condition is true). In your version of the code, the first input thatif is getting is color, and the second one is targetTurtleNum = red, so the compiler complains about getting a boolean as the second input.
In the correct version up here, the whole [ color ] of turtle targetTurtleNum = red part is the boolean that counts as the first input, and [ set target-confirmed true ] is the command block that is expected as the second input.