How can I hide specific duplicate rows in SSRS 2005? - reporting-services

Here's my problem: I have some some duplicate rows (rows with the same ID). What I want is to hide rows based on a specific's column value. The mentioned column is obviously not the ID column (it's the Description column).
I tried this on the Row Visibility (Expression):
=IIF (Fields!Incident_ID.Value = Previous(Fields!Incident_ID.Value)
AND
ReportItems!Description.Value <> "Incident Status Change to Work In Progress from Open", true, false)
So, I want to exclude the rows in which Description is not equal to 'Incident Status Change to Work In Progress from Open'.
The message that I get is:
The Hidden expression for the table 'table 1' contains an error:
Object variable or With block variable not set.
Any ideas on this?
Thanks in advance

I think you are probably getting that error because there are one or more rows in your query result that have a NULL value in the Description field.
You could test this theory by simplifying your expression to this:
=IIF(Fields!Incident_ID.Value = Previous(Fields!Incident_ID.Value), true, false)
just to see if you can run the report without error.
If that works, then you need to add a test for a NULL value as part of the larger condition test, to get back to the logic you intended.
Try this:
=IIF(Fields!Incident_ID.Value = Previous(Fields!Incident_ID.Value) AND IsNothing(Fields!Description.Value) = false AND Fields!Description.Value <> "Incident Status Change to Work In Progress from Open", true, false)
This should avoid the error by preventing the evaluation of the last part of the condition, when the Description has a NULL value.

I think you're on the right track just using ReportItems instead of Fields!
=IIF(Fields!Incident_ID.Value = Previous(Fields!Incident_ID.Value) AND Fields!Description.Value <> "Incident Status Change to Work In Progress from Open", true, false)

SSRS can be wonky sometimes. Try parenthesizing:
=IIF(((Fields!Incident_ID.Value = Previous(Fields!Incident_ID.Value)) AND (IsNothing(Fields!Description.Value) = false) AND (Fields!Description.Value <> "Incident Status Change to Work In Progress from Open")), true, false)

Related

IIF statement with null value and multiple condition

I'm getting a problem with one of my expression in my report. It always gives me #Error and I think I know why but don't know how to set my expression.
Here's my expression :
=IIF(Fields!CMMTTEXT.Value.Contains("*Return*") AND Fields!SOPTYPE.Value = "INVOICE", "*** See return ***", "")
The Fields CMMTTEXT can be null sometimes and I'm getting an error on all of my rows except the one that has data in the CMMTTEXT field.
So I need a isnothing but I've tried couple ways of doing it but doens't seem to work
=IIF(IsNothing(Fields!CMMTTEXT.Value.Contains("*Return*")) AND Fields!SOPTYPE.Value = "INVOICE", "*** See return ***", "")
also this that I've seen on this forum :
=IIF(IsNothing(Fields!CMMTTEXT.Value) OR Fields!CMMTTEXT.Value.Contains("*Return*") AND Fields!SOPTYPE.Value = "INVOICE", "*** See return ***", "")
I have no idea at this point.
Thanks for the help!
The Contains function doesn't work with NULL values. Once it throws an error, the IsNothing function subsequently can't evaluate the results. Separating these out using the OR operator also doesn't work because it tries to evaluate both conditions even when the first one was true.
One way to work around this is to first check for NULL values and replace them with an empty string. Then use the Contains function on the results of this expression:
=IF(IsNothing(Fields!CMMTTEXT.Value), "", Fields!CMMTTEXT.Value).Contains("*Return*")

SSRS how to have two different condition in Action Property

I am working in a SSRS that needs to link a report based on the value in a textbox.
I have tried:
=IIf(Fields!Factors.Value = "Touched Leads","SCPL",Nothing)
Which works fine, but when I try to add another condition like this:
=IIf(Fields!Factors.Value = "Touched Leads","SCPL",Nothing) OR
IIf(Fields!Factors.Value = "TOTAL","Disposition",Nothing)
Then it does not link any report. How do I do this right?
What you are trying does not work correctly as the IIF statements are not nested and what it is doing is:
IIF(this, true part, false part) OR IIF(this, true part, false part)
So when Fields!Factors.Value = "Touched Leads" the expression evalutes to SCPL OR Nothing which isn't valid.
Alternatively you could use SWITCH which has a nicer syntax, the final True statement is your catch all
=SWITCH(
Fields!Factors.Value = "Touched Leads", "SCPL",
Fields!Factors.Value = "TOTAL", "Disposition",
True, Nothing
)
I think that the expression you need will look like this:
=IIf(Fields!Factors.Value = "Touched Leads","SCPL",
IIf(Fields!Factors.Value = "TOTAL","Disposition",Nothing))
This checks the first condition ("Touched Leads"), if that is true, link the SCPL report, otherwise check the "TOTAL" condition. If that one is false, return Nothing.

Hiding table or assigning temp data based on visibility expression ssrs 2008

I have a table in ssrs 2008. This table has a row visibility expression like:
=IIF(max(Fields!VExpected.Value) <> "", 1, 0) +
IIF(max(Fields!MExpected.Value) <> "", 1, 0) +
IIF(max(Fields!PExpected.Value) <> "", 1, 0) = 3, false, true)
Sometimes the datasource returns no data, or the returned data is not matching with this expression. In this case what I see is that a table with borders and column names but no data on it like:
id Vex Mex Pex
However, I want to show it as
id Vex Mex Pex
- - - -
Or if possible:
id Vex Mex Pex
No Data
Another question is, is there any way to hide the complete table if there is no returning data or any matching data with the expression?
Thanks
You can use CountRows function to determine how many rows your dataset is returning. If it is zero hide the table otherwise show it.
=iif(CountRows("DataSetName")=0,true,false)
Replace DataSetName by the actual name of your dataset.
For not matching expression data you can use the this expression.
=IIF(
max(Fields!VExpected.Value) <> "" AND
max(Fields!MExpected.Value) <> "" AND
max(Fields!PExpected.Value) <> "",False,True
)
The whole expression for matching expression and no rows cases could be something like this:
=Switch(
CountRows("DataSetName")=0,true,
max(Fields!VExpected.Value) = "",true,
max(Fields!MExpected.Value) = "",true,
max(Fields!PExpected.Value) = "",True,
true,False
)
Supposing VM, ME and PE expected values are numeric type I'd use ISNOTHING() function to determine when null values are being returned.
=Switch(
CountRows("DataSetName")=0,true,
ISNOTHING(max(Fields!VExpected.Value)),true,
ISNOTHING(max(Fields!MExpected.Value)),true,
ISNOTHING(max(Fields!PExpected.Value)),True,
true,False
)
Additional you can set a message when no rows are being returned from your dataset. Select the tablix and press F4 to see properties window. Go to NoRowsMessage property and use an expression to say your users there is no data.
="There is no data."
In this cases the tablix will not appear in your report but the message you set will be rendered in the location where the tablix should be.
Let me know if this helps.

Ruby MYSQL conditional statement

I have a ruby script which queries the database, extracts some info and publishes the result. The row in the code snippet below is a record(I'm looping through the rows). I have a flag Cancelled [Which is of datatype bit(1)] in the table.
Irrespective of the flag value, I am always publishing Cancelled = 'No'. Basically the conditional statement is always returning false even though that's not the case. Can someone tell me what I'm doing wrong?
db = Mysql2::Client.new(parameters....)
query_str = "Some query"
row = db.query(query_str).first
Cancelled = 'No'
if row['Cancelled'] == true
Cancelled = 'Yes'
end

Combobox null in if statement

I am trying to code an if statement where if a certain combobox is null, then it runs a certain part of code if it has data in it then it runs another. I wrote up this:
Private Sub ProjectAddSetDateAutoBtn_Click()
If ProjectAddAllDueDateAutoCmBx = Null Then
'Code1
Msgbox("ComboBox Is Null")
Else
'Code2
Msgbox("ComboBox Has Data")
End If
End Sub
I leave the combobox with no data, and then it doesn't run the code in the first part of the if or the code in the 2nd part of it either! If I enter data into the box, it runs the 2nd part of the if statement perfectly. There are no errors, I am quite stumped on this. Do ComboBoxes have their own "Null"? Is there a problem with this if statement?
Nothing is ever equal to Null, not even another Null.
Use IsNull() to check whether the combo box is Null.
'If ProjectAddAllDueDateAutoCmBx = Null Then
If IsNull(ProjectAddAllDueDateAutoCmBx) = True Then
I would suggest
If IsNull(ProjectAddAllDueDateAutoCmBx.Value) Then
It correctly checks for Null (IsNull instead of = Null), and it explicitly checks the value of the combo box.
(In most cases -- depending on the context -- just using the name of the control yields the value, but it doesn't hurt to be explicit.)
You cannot use a = Null comparison to get the results you want because Null propagates. To see this in action, try:
? Null = Null
in the Immediate Window and you'll see that Null is returned. Use the IsNull function, which will return true or false as you would expect.
Private Sub ProjectAddSetDateAutoBtn_Click()
If IsNull(ProjectAddAllDueDateAutoCmBx) Then
'Code1
Msgbox("ComboBox Is Null")
Else
'Code2
Msgbox("ComboBox Has Data")
End If
End Sub
While the accepted answer is totally correct, I use a different approach:
If HasValue(ProjectAddAllDueDateAutoCmBx) Then
where the HasValue function is:
Public Function HasValue(v As Variant) As Boolean
If Trim(v & "") <> "" Then
HasValue = True
Else
HasValue = False
End If
End Function
This has the advantage of treating NULL and "" (or any pure whitespace) values the same, which is many times what you want with MSAccess controls. For example entering a value in a null-valued textbox and removing it again with backspace will result in a ""-value, not NULL. From a user-perspective this is mostly meant to be the same.
[The (v & "")-part is just a trick to force conversion to a string.]
the equivalent of null in VB is Nothing so your check wants to be:
If ProjectAddAllDueDateAutoCmBx Is Nothing Then
....
it hope helps.