I have an SSRS report that is based on a parameter that can have multiple values. For example: '0','1' and '0','2' (like an IN statement).
Now, I have to show certain parts in the the report whenever the parameter is 0 AND 1, and hide certain parts in the report whenever the parameter is 0 AND 2.
But… This 0 value is always the issue here. I know I have to use the visibility expression for this, but I cannot seem to write the correct expression.
So, when my parameter (Parametername = Prognosis) is (0 and 1), I need the component to show. When my parameter is (0 and 2), I need the component to hide. By the way, it is never just '0', or just '1', or just '2'.
I tried this, but no success:
=IIF(Parameters!Prognosis.Value(0) = 0 and Parameters!Prognosis.Value(0) = 1,False,IIF(Parameters!Prognosis.Value(0) = 0 and Parameters!Prognosis.Value(0) = 2,True,False))
Could someone help me with writing this expression?
Thank you guys
Use join() to put the values of the parameter into a string. So it would be..
=join(Parameters!Thingy.Value, ",")
Then you can see what values are returned by the string. e.g.
=iif(join(Parameters!Thingy.Value, ",") = "0,1", TRUE, FALSE)
Related
I am trying to figure out the best way to handle this. I have a series of form fields with checkboxes for people to select options. When that gets submitted it turns form.optiongroups into an array. I then check to see if the id of the optiongroup is in the array and set the checked value to true in case there were form errors I want them to retain their checked value. This all works fine.
If I only select one option though it doesn't come through as an array, but just a regular form field. Is there a way I can handle this to make sure it is always an array?
Actually, checkboxes get submitted as a list. You must have something else going on that creates the array.
However, to answer your question as asked, you can use ListToArray(). It would be something like this:
if (structkeyexists(form, 'optiongroups') { // if no boxes are checked the variable will be undefined.
if (isArray(form.optiongroups) == false )
form.optiongroups = ListToArray(form.optiongroups)
} else {
code for no boxes checked
}
It could also be done via...
param form.optiongroups = "";
form.optiongroups = ListToArray(form.optiongroups);
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.
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
Im trying to send some checkbox values as an array and then insert it to my database, but I can't get the array values into variables in my asp page?
I want to get the array values into variables kalnr0=arrayvalue0, kalnr1=arrayvalue1 etc…
I have this now: And it shows the alert(texten) that say its an array.
Im sending the form with ajax method="GET"
and the form field:
<input type="checkbox" name="kalendrar_id[]" value="<%=rs("kalendrar_id")%>">
and on my receiving asp page I have this:
Dim kalendrar_id
kalendrar_id=request.querystring("kalendrar_id[]")
kalitem = Split(kalendrar_id, ",")
japp=array(kalitem)
If IsArray(japp) then
For i = 0 To UBound(kalitem)
On Error resume next
Response.Write kalnr(i)=i
Next
texten= " is an array"
Else
texten= " not an array"
End If
So how do I get the array values into the below variables?
kalnr0=Cstr(kalitem(0))
kalnr1=Cstr(kalitem(1))
kalnr2=Cstr(kalitem(2))
kalnr3=Cstr(kalitem(3))
kalnr4=Cstr(kalitem(4))
I really need some help with this, thanks :-)
If I set kalendrar_id="1,2,3,4,5" then it works, so kalendrar_id=request.querystring("kalendrar_id[]") is not getting any value, or its the wrong value!?
And if I post the form the normal way, not with ajax then it works, so somehow the query string request.querystring("kalendrar_id[]") is wrong, could it be something with encoding?
SOLVED. I had to remove [ ] from the form field, not sure what else, have tried so many things ;-)
First off, if your question is how to put something like the following into a loop...
var1 = var(1)
var2 = var(2)
...
var5 = var(5)
... the answer is don't do that. :) ("Doctor, it hurts when I press here." "So don't press there.")
Second, you don't need to use both Split() and Array(). Split() already produces an array, so the second function isn't doing anything useful.
Third, I'm not sure why you're using square brackets in the field names. If you think they'll somehow magically make your form return an array, well, they won't. All they'll do is make some servers eat your form results. (Not all servers, which is why square brackets are allowed in form field names, but they're still not a good idea, especially with method="get".)
To debug an issue like yours, the first thing to try is to look at what the form is returning. With method="get", you could just look at the querystring in the address bar, but it's better to explicitly see what the server thinks it's getting:
Response.Write "fieldname=" & Request.Querystring("fieldname") & "<br>"
If that doesn't get you what you expect, then you need to make sure the form field is actually named what you think it is. If yes, the next step is to double-check that the form is getting filled out - i.e. is the reason it's not returning a value the fact that there's no value to return?
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.