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:
Related
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").
I am trying to create a receipt form where people will confirm if they've received the full quantity of an order. As part of this, I want the following to happen:
If they received the full quantity, a green check mark appears
If they received a partial quantity, an orange triangle appears
If they received no items, a red x appears
To accomplish this, I'm using a continuous form with 3 image files for each situation. I'm using the code below to change the image when the quantity is changed. The problem is, when the quantity is change on 1 line, the symbol changes for all lines. I'll post pictures as well.
Any thoughts on how I can fix this?
I'm open to other methods of accomplishing this idea too.
Private Sub FinalQTY_AfterUpdate()
If IsNull(Me.FinalQty) Then
MsgBox "You must enter a quantity for this item"
Me.FinalQty.SetFocus
Exit Sub
Else
LValue = Me.[FinalQty]
If IsNumeric(LValue) = 0 Then
Me.FinalQty = ""
MsgBox "Qty must be a numeric value"
Me.QTY.SetFocus
Exit Sub
End If
End If
Me.FinalTotalPrice = Me.FinalPrice * Me.FinalQty
If Me.FinalQty = 0 Then
Me.Yes.Visible = False
Me.Change.Visible = False
Me.No.Visible = True
End If
If Me.FinalQty < Me.QTY Then
Me.Yes.Visible = False
Me.Change.Visible = True
Me.No.Visible = False
End If
If Me.FinalQty = Me.QTY Then
Me.Yes.Visible = True
Me.Change.Visible = False
Me.No.Visible = False
End If
End Sub
This is before I adjust the quantity:
This is after I adjust the qty of only the second line:
Since the formatting of each record displayed by a continuous form is inherited from the form design template, any changes to the template will be automatically applied to all records displayed by the form, aside from Conditional Formatting rules in effect or the handful of properties which may changed via the OnPaint event of the Detail section.
One possible alternative might be to add a new field to your table with a data type of OLE Object and populate the value on the AfterUpdate event using the AppendChunk method, sourcing image data from a separate table containing three records corresponding to your green tick, orange triangle, and red cross images.
I've attempted to create an expression which should calculate when a field equals 'Mid' and another equals 'Red' then calculate a percentage based on a field / specific number.
Here are my attempts so far:
=count(IIF(Fields!loc.Value="Mid" AND Fields!Status.Value ="Red",1,Nothing)) / count(Fields!Total.Value / 500) *100
=IIF(Fields!loc.Value="Mid" AND Fields!Status.Value="Grey",(FormatPercent (Count(Fields!Total.Value) / 500 ,0))
Expected results from the calculation would be a percentage: 34.83% (to two DP)
Loc field contains locations: Mid, Lon, Manc, Newc etc etc
Status field contains colours for statuses: Red, Green, Blue, Yellow etc etc Total field contains 'total' values for locations.
Neither seem to work and I'm getting myself confused. Once this one part is done, I can then add multiple locations and colours too.
Supposing a dataset like this:
Loc Status Total
Mid Red 100
Mid Red 200
Lon Blue 90
Manc Yellow 50
And you want to calculate the percentage of occurrences where Loc = "Mid" and Status = "Red" Using an expression like this:
=COUNT(
IIF(Fields!Loc.Value = "Mid" and Fields!Status.Value = "Red",Fields!Loc.Value,Nothing)) /
COUNT(Fields!Loc.Value,"DataSetName")
Replace DataSetName by the actual name of yours.
You will get 2/4 = 0.5 (50%) if you format the cell to a percentage number.
Hope it helps.
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")
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.