How to stop an SSRS report with optional parameters from rendering - sql-server

I have a report that has multiple parameters. The user will filter the data by inputting a value in to one of them.
All the parameters are created by the query and have the following design (fieldname = #param OR #param IS NULL)
In the parameter properties window, they have been changed to allow NULL values. The issue with this, is that the report renders initially with all data returned, as each parameter has the NULL checkbox ticked as default. From there you can input a value to one parameter and the report will filter as desired.
I would prefer the report not to render until one value has been given to one of the parameters. I am aware I can use a default value for one of the parameters, which would return no data, but this isn't ideal, as you still get the rendering of the report.
Is there a way to run the report but not render until a value is passed to one parameter?

-Write a custom code that checks the parameter value
Function GetReportCode(ParamVal AS String) As integer
Return IIf(ParamVal Is Nothing, 1/0, 0)
End Function
-If your parameter value is NULL then it will return an arithmetic overflow error
-Create a new variable with help of the following experision.
code.GetReportCode(Parameters!ReportParameter1.Value)
If the parameters takes NULL values it will return an error.

Related

Flurry-ParamDistribution comparison

I am sending event(event_payment_result) with more than one params and I am reviewing the parameters sent from Events > Parameter Distribution section. In this screen I can show only one parameter of event.
But I want to compare different params for this event. Are there any features for this comparison process? For example payment_type = Mastercard and is_succeed = TRUE
On the Parameter Trend dashboard, you can compare parameter values from different parameters over time. Use the context boxes at the top to choose the Event param names, in your example "payment_type" and "is_succeed", then the boxes just above the graph to select the values, "Mastercard" and "TRUE". You will then see the two values compared over time.

Need expression to appear somewhere else

I have a report which uses an expression to provide data for each particular page. I have been able to get the report to display the correct data, however the column that the expression is in, is not necessary and the rest of the table will not fit on the page. I need to get rid of the column but reference the expression somewhere else on the report. I have tried a few things, such as referencing the text box but get Scope errors.
I would like the expression to display where the green line is, and make the first column invisible.
Any ideas how I can reference the value of this textbox in the desired location?
Current state of report:
expression ="Load Number: " & Fields!TPLD_SYS_NO.Value & " | " & "Vehicle:" & Fields!TPLD_TPVH_REG.Value & " | " & Fields!TPLD_REF.Value
expression used to reference 1st expression =ReportItems!TPLD_SYS_NO1.Value
error The value expression for the textbox 'textbox8' refers to the report item 'TPLD_SYS_NO1'. Report item expressions can only refer to other report items in the same grouping scope or a containing grouping scope
This is from memory, zero testing I'm afraid so it might not be quite right but it should be close enough to follow.
A couple of options.
If the report will only ever show one value for this expression then you should be able to just use your original value expression directly in the 'new' text box but where you have Fields!myField.value, replace these with FIRST(Fields!myField.Value, "myDataset") where myDataset refers to the name of your dataset (you must include the quotes).
If the report is grouped so this expression will evaluate to two or more different values then you need to add a row inside the lowest group that will have all the required fields in either itself or child groups. As I guess I would say that would be the same level as your Total textbox. So Insert Row / Inside Group Above and then use the expression above but without the dataset name. You should be able to not specify this or if you get problems, specify it as the name of the rowgroup that your new textbox sits in.
To get an out of scope value, you can create custom code functions to store the value and assign the text as follows :
="Load Details" + Code.Save_TPLD_SYS_NO(Fields!TPLD_SYS_NO.Value)
When you need to recall the value at some other point you can reference a function that returns the saved value like:
=Code.GetSaved_TPLD_SYS_NO(true)
In your custom code you can create a variable that will hold the value and that the function would be something like:
NOTE : This is untested and the code comes from memory, you may have to fiddle a bit to get the correct syntax.
Public Dim Shared TPLD_SYS_NO As String ="";
function Save_TPLD_SYS_NO(value As String) As String
Begin
TPLD_SYS_NO = value
Return ""
End Function
function DisplayAndSave_TPLD_SYS_NO(value As String) As String
Begin
TPLD_SYS_NO = value
Return value
End Function
function GetSaved_TPLD_SYS_NO(resetValue as Boolean) As String
Begin
Dim result As String = TPLD_SYS_NO
If resetValue=true Then
TPLD_SYS_NO = ""
End If
Return result
End Function

Drop Down Parameter Not Returning a Value For a Query

I have a database set up which includes a query and a form, which are causing me problems. In the form, I have a drop down menu which allows you to select from a list of ID values (e.g. 1, 2, 3, ...). Once you have selected a value, you then click a button and it runs the query with a parameter of the ID number from the drop down ([Forms]![KitInfoRetrievalForm]![DropDown]).
The problem here though, is that when I select something from the drop down menu and click the button to run the query, it gives a pop up box asking for a value to substitute in for [Forms]![KitInfoRetrievalForm]![DropDown]. This leads me to believe that either the drop down menu is a null value for some reason or my pathing to it is incorrect.
This was working at one point and then stopped after a series of weird error messages from something else entirely (in the same Access project). Any help you can give me would be much appreciated.
I would recommend to replace reference to dropdown in query by function. It should eliminate this problem and also this is a workaround for old bug in Access, which exists in all recent versions: if the form/subform is in datasheet mode and you applied filter (quick filter thru user interface or using VBA), it stops reading variables with references to controls or just parameters and uses last used value.
I'm using this function for reading form/subform control value:
Public Function GetControlValue(strFormName As String, strControlName As String, Optional strSubFormControlName As Variant) As Variant
On Error Resume Next
If IsMissing(strSubFormControlName) Then
GetControlValue = Forms(strFormName).Controls(strControlName).Value
Else
GetControlValue = Forms(strFormName).Controls(strSubFormControlName).Form.Controls(strControlName).Value
End If
End Function
In your case replace [Forms]![KitInfoRetrievalForm]![DropDown] by
GetControlValue("KitInfoRetrievalForm","DropDown")

Password matching in AngularJS using the $validators pipeline produces unexpected results

See the example here.
Using the $validators pipeline, I am trying to check that a field contains the same value as another field.
Each input in this example is associated with the other, such that the expected result is as follows:
Enter a value in input#1
Enter same value in input#2
Both fields should now be valid
Alter the value in input#1
input#1 should be invalid (or input#2 or both)
Initially, I did this using a $watch on both the current model and the target to be equal to, so only one of the two fields needed to use the directive. However, with the introduction of the $validators pipeline, this method stopped working unexpectedly (maybe a bug).
Anyhow, as you can see, when the second input is altered, the value is receives for the associated input is undefined.
Solution
I solved this by the following:
JSFiddle
As Nikos said, the two instances were cancelling each other out, so this was fixed by the following code:
$scope.$watch('passwordWatch', function(pass) {
$control.$validate();
});
So now, when the target input changes, the current input revalidates. When the current input changes, it validates automatically (as usual).
One problem is that when a validator fails (returns false), then the underlying model value is set to undefined. So:
You type something in the password, say "aaa"; this is NOT the same as passwordConfirm, so the validator returns false and the model gets the undefined value
You type the same value in passwordConfirm; but from above the value of the password is undefined and undefined !== "aaa", so the passwordConfirm validator returns false too.
And so on...

Filter list by custom code in Reporting Services 2005?

Can you do this? The list filter I want to use looks like this:
Expression Operator Value
=Code.GetOccCat(Fields!accountnumber.Value) = =1
No dice. Basically, it acts like that function returns null as far as the filter is concerned, but when I take the filter off and put the exact same function call in a text box within the list, it returns what it's supposed to return. Can you just not do this, or what am I missing?
Edit: here's the function, completely simple:
Public Function GetOccCat(ByVal AccountNum As Integer) As Integer
Return OccCat(AccountNum)
End Function
OccCat is a public array of integers that is filled via an earlier function call. Again, the correct values display if I just put this in a text box, so the array is verified to be filling up correctly.
Edit: the array gets populated by way of a list at the top of the report. The list repeats on accountnumber with no filter. Inside the list is a textbox containing this code:
=Code.SetOccupancy(Fields!accountnumber.Value, First(Fields!new_total_hours.Value)/First(Fields!new_capacity.Value))
And here's that function:
Public Function SetOccupancy(ByVal AccountNum As Integer, ByVal Occ As Double) As String
Occupancy(AccountNum) = Occ
Select Occ
Case Is > .85
OccCat(AccountNum) = 1
Case .7 to .849
OccCat(AccountNum) = 2
Case .4 to .699
OccCat(AccountNum) = 3
Case Is < .4
OccCat(AccountNum) = 4
End Select
Return ""
End Function
FWIW, I've also tried this filter based on the Occupancy array (being > .85 in this case) and gotten the same result.
Could you show your function in your code?
I just checked it, and it certainly works to filter off of custom code. Though I didn't use yours exactly because I don't quite understand what you are trying to filter by.
Which field are you wanting to filter by?
I think you are just putting your code for your expression in the wrong place. Basically, put the field you want to filter by in the expression box that drops down. Then place your =code.getocccat(my value) in the value expression.
Try this and let me know, but it certainly works. I think you have the placement a little off.

Resources