I am trying to do an and/or statement for a field in my report, and I am getting an error. If I just do the one without the "or" is works fine. Is there a different way I need to code this?
=IIf(Fields!NOP.Value = "1","Consulting Fee","") or IIf(Fields!NOP.Value = "3","Honoraria","")
From what I've been able to tell there is no formal "OR" statement in SSRS expressions, what you might try is a switch:
=Switch(Fields!NOP.Value = "1", "Consulting Fee", Fields!NOP.Value = "3","Honoraria")
Nested IIF statements should work:
=IIF(Fields!NOP.Value = "1", "Consulting Fee", IIF(Fields!NOP.Value = "3", "Honoraria", ""))
Related
This seems simple but I could not find an answer. I have a form and all inputs are put in an object. Now the backend requires the form object to be wrapped in an array. So I have this :
<input
class="input"
placeholder="Serial #"
v-model="form.serialNum"
/>
// etc for form
and in <script setup>
let form = reactive({
eqpmntType: "",
make: "",
modelNum: "",
// etc
So I read docs and understand reactive function is for objects so I tried ref():
let form = ref([{
eqpmntType: "",
make: "",
modelNum: "",
//etc
}]
And unfortunately I lose my reactivity for the form inputs. I know I can wrap the form object in an array after the fact and submit. I was wondering if there is a way to make an array or for that matter an array of objects reactive. Thanks for any clarification.
I think your initiated form is reactive and have no problem to me. Maybe it is how you use it.
For example, if you want to alter the value of modelNum within form, since it is an Array type now, make sure you did this:
form.value[0].modelNum = 123
And in the input element, the v-model should be v-model="form[0].modelNum" also because of type Array.
Althogh I don't see why the backend requires you to pass Array-type params since it seems form only contains 1 Object within the array. Normally, in below case, Array-type params will be adopted:
const form = ref([
{
eqpmntType: "1",
make: "1",
modelNum: "1"
},
{
eqpmntType: "2",
make: "2",
modelNum: "2"
},
{
eqpmntType: "3",
make: "3",
modelNum: "3"
},
])
In this case, your input must be more than one so that each v-model of one input will bind each modelNum respectively. So if this answer doesn't solve your problem, I would like you to display more code and details.
My problem is very similar to what is described here but unfortunately I am unable to apply the code in the specific situation I am in.
So I am trying to download many URLs and I am using a for loop to get this done. This is how my loop might look like:
ids <- c("1", "3", "7", "9")
numbers <- list()
for (jj in seq_along(ids)) {
numbers[[jj]] <- as.numeric(ids[jj])
}
That works all dandy. Until I receive the Error "Error: Try Again", which randomly appears but can be fixed if I just start the loop again at the same place.
However, there is a different error which signals that the API key I am using has expired "Error: Stop for loop", and for this error I need to stop the loop, restart the API key manually (can't be automated unfortunately) and then start again at the iterator where it left off.
So to simulate this I wrote this little loop:
errors <- c("Error: Try Again", "Error: Stop for loop")
numbers <- list()
for (jj in seq_along(ids)) {
numbers[[jj]] <- as.numeric(ids[jj])
if (jj == sample(1:4, 1)) stop(sample(errors, 1))
#randomly stops and gives one or the other error
}
So here is what I want to do:
Whenever my for loop hits "Error: Try Again", I want the loop to try again until it works.
Whenever my for loop hits "Error: Stop for loop", I want the loop to stop so I can manually fix the API key error. In this case I want the results of the loop saved, so I can later rbind them together when I restart the loop.
Unfortunately, I am very unskilled in writing these kind of conditions. I know that I have to use try or tryCatch somehow but I am unable to figure out how I can test for specific error messages (rather than if an error occured at all).
Thank you for the help everyone!
I think something like this is good. I pulled the error-generating part into its own function to make things more modular and easier to understand.
To easily "try things until success", a while loop makes more sense than a for loop. We can break to stop the loop. I've used next to jump to the next iteration of the loop, though it really isn't needed here (using it would skip everything left in the loop for the current iteration - but since there's really nothing that happens after my next statements they could be left out).
ids <- c("1", "3", "7", "9", "12", "13", "18")
foo = function() {
errors <- c("Error: Try Again", "Error: Stop for loop")
if (runif(1) < 0.25) stop(sample(errors, 1))
}
numbers <- list()
jj = 1
while(jj <= length(ids)) {
numbers[[jj]] <- as.numeric(ids[jj])
outcome = tryCatch(foo(), error = function(e) e)
if (is.null(outcome)) {
jj = jj + 1
next
} else if (outcome$message == "Error: Stop for loop") {
message("Loop stopped on iteration ", jj)
break
} else if (outcome$message == "Error: Try Again"){
next
}
}
I'm new to classic asp and I'm trying to figure out this simple if else statement.
For some reason it's just recognizing person 2 and not even trying person 1?
Any idea on how to fix? Thanks
This is my code:
<%
Dim GetPath
GetPath = request.ServerVariables("URL") & query_string
Dim page
page = "/products/dowlex/index.htm"
if GetPath = page then
varrecipient = "email1#email.com"
Response.Write("*Path = " & GetPath)
Response.Write("Person 1")
else
varrecipient = "email2#email.com"
Response.Write("*Path = " & GetPath)
Response.Write("Person 2")
end if
varFormName = "Contact"
varRHBusinessUnit = "businessname"
varLanguage = "ENGLISH"
varCourtesyResponse = "Y"
varRedirect = "#noredir?formRun=true"
varSubject = "Ask an Expert Form"
%>
I would compare the two strings based on the same case...
if UCase(GetPath) = UCase(page) then
And of course, if query_string ever has a value, then the 1st case will never be true.
The formatting of your statement is fine. If... Then... Else... End if.
I would do a Response.Write("GetPath") to see if you are getting back, what you think you should be.
I have a couple thoughts.
1) Can you use Response.Write to display what's in "GetPath" before the if statement? That might help you see what's going wrong!
2) Try changing the variable names. The editor is making "GetPath" blue, as though it's a reserved word. That might be messing things up.
I'm sorry guys, I messed up a small code and thats why it wasn't working.
I forgot to complete the full path of the site. Thanks for all your help and suggestions!
*Path = /plasticpipes/eu/products/dowlex/index.htm
*Page = /products/dowlex/index.htm
I'm trying to use a ternary operator in Razor, similar to this question, but what I want to output contains whitespace. This code
#(selectedGoal == null ? "" : "value=" + selectedGoal.Name)
should produce
value="Goal 3"
as the value of selectedGoal.Name is "Goal 3". Instead, I get
value="Goal" 3
which is no good. I've tried a bunch of different combinations of escaped quotes, # symbols and no # symbols, and I just can't get this to work, i.e.
#(selectedGoal == null ? "" : "value=" + "selectedGoal.Name")
#(selectedGoal == null ? "" : "value=#selectedGoal.Name")
and then I just get something like
value="selectedGoal.Name"
Anyone know how this should be done?
Your value attribute is missing its own quotes, so they are being automatically added before the space. Try moving value outside of the expression.
value="#(selectedGoal == null ? "" : selectedGoal.Name)"
What about
#(selectedGoal == null ? "" : "value=\"" + selectedGoal.Name + \")
Or you can try rendering them directly as an HTML block, using my method on
Html literal in Razor ternary expression
Please can you someone help me?
My question is :
How to use properly OR in IIF
statement in RDLC report?
Both Fields!A.Value and Fields!B.Value contains string or empty string.
This code works fine:
=Iif(Len(CStr(First(Fields!A.Value, "dsResult_dtRows")))=0, True, False)
This code doesnt work:
=Iif(Len(CStr(First(Fields!A.Value, "dsResult_dtRows")))=0 Or
Len(CStr(First(Fields!B.Value, "dsResult_dtRows")))=0, True, False)
thanks a lot for ideas and answers
-marek-
you should be able to concatenate the field values and test for the empty string instead of testing each value individually.
try
IIF(Fields!A.Value & Fields!B.Value = '',true,false)
for either empty returning true, try:
IIF(Fields!A.Value ='' or Fields!B.Value = '',true,false)