SSRS Row Visibility - reporting-services

I am using the Switch function in Reporting Services to determine the visibility of a row. It happens that I am using more that one column or field to test my expression like so:
=Switch(Parameters!View.Value = "Green" AND Fields!Tax.Value = "N",TRUE,Parameters!View.Value = "Current" AND Fields!PastVal.Value = 0 AND Fields!DatePay.Value = 0 AND Fields!Comment.Value = 0,True)
With the expression above, I want that if the first part is true, the row should be hidden likewise for the second part of the expression, I want to hid a row when all the conditions are met. But this not yielding the desired result.
I equally tried with another expression like so:
=IIF(Parameters!View.Value = "Green" AND Fields!Tax.Value = N",False, IIF(Parameters!View.Value = "Current" AND Fields!PastVal.Value = 0 AND Fields!DatePay.Value = 0 AND Fields!Comment.Value = 0,True,False))
That still did not work.
I anticipate your help. Thank you

If I follow you correctly, I think putting both conditions in an IIF and separating them with an "OR" will work:
=IIF( (Parameters!View.Value = "Green" AND Fields!Tax.Value = "N") OR (Parameters!View.Value = "Current" AND Fields!PastVal.Value = 0 AND Fields!DatePay.Value = 0 AND Fields!Comment.Value = 0) ),True,False)

Related

SSRS multiple iif statements rounds instead of keeping 2 decimal calculation

I have the following statement in a calculated field that will only return whole numbers instead of a 2 decimal dollar amount. If I only use one of the 3 iif conditions it works fine but as soon as I add the second or all 3 it will not return a decimal value. Ive also tried all 3 iif conditions separaately and they all work. It appears to be just the OR's causing the issue???
=
(iif ((Fields!loc.Value = "C08") OR (Fields!loc.Value = "C09"), Fields!price1.Value, Fields!price1.Value - Fields!price2.Value) )
OR
(iif ((Fields!loc.Value = "C33") OR (Fields!loc.Value = "C32") OR (Fields!loc.Value = "C10") OR (Fields!loc.Value = "C30"), 0, Fields!price1.Value - Fields!price2.Value) )
OR
(iif (Fields!price1.Value = 0, 0, Fields!price1.Value - Fields!price2.Value))
You can't write and IIF like that, you would need to nest you IIFs which would get a bit messy.
You might find it easier to use a SWITCH statement which is a bit easier to read.
I might not have understood your logic properly but it should be close enough. Note that the first expression that returns true is what will get returned so in thsi case I have assume that if price1 is 0 then the returned value will always be zero, if this is incorrect, just re-order the expression pairs
=SWITCH(
Fields!price1.Value = 0, 0,
Fields!loc.Value = "C08" OR Fields!loc.Value = "C09", Fields!price1.Value,
Fields!loc.Value = "C33" OR Fields!loc.Value = "C32" OR Fields!loc.Value = "C10" OR Fields!loc.Value = "C30", 0,
True, Fields!price1.Value - Fields!price2.Value
)
This reads... "If price1 is zero then return 0" else "if loc is C08 or C09 return price1" else "if loc is C33, C32, C10 or C30 then return 0". Finally, if no previous test return true, then return price1-price2 .
The final True acts like and else
This could be simplified but I wanted to leave it as close to your original attempt as I could.

Font color expression for group sums

I have data in an SSRS report that groups and provides percentages. I need to change the font color for the percentages and I can't figure out how to create the expression.
Currently I obtain the percentage with this formula:
Sum(Fields!Time_Msg.Value)/Count(Fields!Driver.Value)
The Time_Msg field is obtained from SQL. I want the font expression to be the greater of three colors using this formula:
IIF(Fields!Time_Msg.Value = 1, "green",
IIF(Fields!Time_Msg.Value = 0
And Fields!Time.Value > Fields!TimeB.Value, "red", "yellow"))
So essentially if the record is on time the font will be green, if the record is late then red and early then yellow.
But what do you do when providing grouping sums? If from all the records the greatest value is green, then the font for the grouping sum should be green, etc.
Sorry for formatting as I'm new to this forum..
go to Textbox properties-> Font -> Color and type an expression like this
Instead of using IIF please try to use Switch statement.
= switch(Fields!Time_Msg.Value = 1, "green",
Fields!Time_Msg.Value = 0
And Fields!Time.Value > Fields!TimeB.Value, "red")
Note: Put your condition in switch statement.
Let me know if this works
You can use custom code in your project
Function SetColor(ByVal Value As Integer) As String
Dim Ret as string
Dim doubleVal As Double
Ret = "Blue"
Dim Val As Double
doubleVal = System.Convert.ToDouble(Value)
if Value >= .86 then
Ret = "OliveDrab"
ElseIf Value <=.86 then
Ret = "IndianRed"
end if
End Function
assign whatever numbers you want to whichever colours you are using (I'm using greater or less than 86%) and set the font colour expression to =Code.SetColor(Me.Value)

Only first pass trough logic gates raising a flag, second deactivating it, others doing nothing

I would like to model a bitarray of flags, where only the first pass through a logical expression sets a flag, but the second pass (computing with the previous state) deactivates the flag and all other passes do nothing to it.
I cannot think of a right combo of the previous state, the right logical expression and a second input (0/1).
bitarray[i] = operand(bitarray[i], value_making_a_change)
Desired value after the 1. pass: bitarray[i] = boolean_value.
Desired value after the second pass: bitarrayp[i] = neg(boolean_value).
Desired value after every consequential pass: bitarrayp[i] = neg(boolean_value).
I think I could just test the value, but my bitarray could get quite large, so I would not want to do that for every index. Is there a standard logic gate/expression I could use?
I tried just using XOR(old_value, 1), but that changes the value back and forth:
value = 0
value = XOR(value, 1) = XOR(0, 1) = 1
value = XOR(value, 1) = XOR(1, 1) = 0
value = XOR(value, 1) = XOR(0, 1) = 1
...

Visibility of report field dependent on the value of another field

I have two columns one [CUS SKU], the other [UPC].
I have 2 specific id's 1234, 1233 and many others but only care if these two show up.
My problem-
If either of these two show up on both columns I only want to display one column and hide the other.
If another id is displayed in both columns display both.
If another id shows up on either column and neither of the two important ids are shown then display in either of the columns.
also the two important id's will sometimes have 0 or 00 in front, how do i accommodate for that in there as well.
this is what i tried in each column but had no luck, it was displaying the same.
=IIF (Fields!CUS_SKU.Value = ("1234") or Fields!CUS_SKU.Value = ("1233") and Fields!UPC.Value = ("1234") or Fields!UPC.Value = ("1233"), True, False)
and
=IIF (Fields!CUS_SKU.Value <> ("1234") or Fields!CUS_SKU.Value <> ("1233") and Fields!UPC.Value = ("1234") or Fields!UPC.Value = ("1233"), False, true)
When mixing AND and OR in a condition, you need to use parens carefully. Try this:
=IIF ((Fields!CUS_SKU.Value = ("1234") or Fields!CUS_SKU.Value = ("1233")) and (Fields!UPC.Value = ("1234") or Fields!UPC.Value = ("1233")), True, False)

Creating a value in a control on a form

I need to create a value in a text box control upon triggering a certain event to allow me to then relink my forms to a different master/child link scheme. This value is to be used subsequently to create an if statement. For some strange reason, the value is generated and formatted correctly but regardless of what is in the text box, the If statement does not recognise this value and knows it only as blank. I tried numbers, letters but everything is the same.
In my example below, after updating the control (text box) 'txtDeviation' to the value of '1', for some strange reason is not recognised in as the value 1.
Private Sub cmdSkillsTracking_Click()
Form_frmValueChain01!frmValueChain02.SetFocus
Form_frmValueChain01.Pagina370.Visible = False
Form_frmValueChain01.Pagina371.Visible = True
If txtDeviation01 < 1 Then
Form_frmValueChain01.Form.frmValueChain07.LinkMasterFields = "txtMicroProcess01e"
Form_frmValueChain01.Form.frmValueChain07.LinkChildFields = "ID"
Form_frmValueChain01.Form.frmValueChain17.LinkMasterFields = "txtSubProcessID"
Form_frmValueChain01.Form.frmValueChain17.LinkChildFields = "IDskillsmatrix"
Form_frmValueChain01.Form.frmValueChain16.LinkMasterFields = "txtSubProcessID"
Form_frmValueChain01.Form.frmValueChain16.LinkChildFields = "ID"
Else
Form_frmValueChain01.Form.frmValueChain07.LinkMasterFields = "txtMicroProcess01f"
Form_frmValueChain01.Form.frmValueChain07.LinkChildFields = "ID"
Form_frmValueChain01.Form.frmValueChain14.LinkMasterFields = "txtMicroProcess01f"
Form_frmValueChain01.Form.frmValueChain14.LinkChildFields = "subprocessID"
Form_frmValueChain01.Form.frmValueChain10c.LinkMasterFields = "txtMicroProcess01f"
Form_frmValueChain01.Form.frmValueChain10c.LinkChildFields = "ID"
Form_frmValueChain01.Form.frmValueChain101.LinkMasterFields = "txtMicroProcess01f"
Form_frmValueChain01.Form.frmValueChain101.LinkChildFields = "ID"
Form_frmValueChain01.Form.frmValueChain07.LinkMasterFields = "txtMicroProcess01e"
Form_frmValueChain01.Form.frmValueChain07.LinkChildFields = "ID"
Form_frmValueChain01.Form.frmValueChain17.LinkMasterFields = "txtSubProcessID"
Form_frmValueChain01.Form.frmValueChain17.LinkChildFields = "IDskillsmatrix"
Form_frmValueChain01.Form.frmValueChain16.LinkMasterFields = "txtSubProcessID"
Form_frmValueChain01.Form.frmValueChain16.LinkChildFields = "ID"
End If
Two things I see here;
Since you are using a less than operator, you seem to want to treat
this text box value as numeric. If so, you will need to convert the
text value of the text box to numeric.
Next,you need to prefix the reference to the text box with "me."
Your IF statement should look like this;
If val(me.txtDeviation01) < 1 Then
...