Im trying to sum an expression in visual studio and just keep getting an #error but not sure why as this si the first time i have tried to sum an expression, only ever done it on a single field before. Any Suggestions!!!
=IIf(Fields!STATUS.value = "Completed" AND Fields!DONOTINVOICE.value = True, Fields!ORDERCOST.Value, "")
The value of the IIf() will evaluate to a string ("") when your condition is false. You can't sum a string. Try using 0 instead.
Do you mean like this, just tried that and dosent sum anything just get 0 :(
=Sum(IIf(Fields!STATUS.value = "Completed" AND Fields!DONOTINVOICE.value = 1, Fields!ORDERCOST.Value, 0))
Ok couldnt figure out the sum on an expression so ive just used a case statement in a new dataset to build the sum feature. Example below, this is in an inner query and i have done a sum in the main bit. Just incase anyone else gets this issue this is how i resolved it.
CASE
WHEN TBL_REPAIR_ORDER.STATUS = 'Completed' AND TBL_REPAIR_ORDER.DONOTINVOICE = 1 THEN TBL_REPAIR_ORDER.ORDERCOST
ELSE 0
END AS Completed
=Sum(IIf(Fields!STATUS.value = "Completed" AND Fields!DONOTINVOICE.value = 1.0, Fields!ORDERCOST.Value, 0.0))
You have to use ".0" at the end of value: this make sure that your return value of if expression is not string
For Visual Studio, wrap the IIf in a Cdbl:
=SUM(CDbl(IIf(Fields!STATUS.value = "Completed" AND Fields!DONOTINVOICE.value = True, Fields!ORDERCOST.Value, 0)))
Related
I have a Boolean parameter called WLH where if True then it should ignore everything but if False then it should show a 0 for every craft textbox in a row that has the word "LABORER" in it. This is the expression that I am using but it doesn't seem to be doing anything. Can I get help on making it work? What am I doing wrong?
=IIF(Parameters!WLH.Value = false AND ReportItems!craft.Value LIKE "*laborer*", 0, ---main calculation for the else statement---)
Two things I see with this expression that need closer attention.
Parameters!WLH.Value = CBool("false"): The false side of the equality test needs to be converted to a boolean type with the CBool (conver to boolean) function.
ReportItems!craft.Value.IndexOf("laborer") >= 0: SSRS doesn't support LIKE in expressions but we can test for the existance of a substring in this manner. What this is doing is looking for the index (where the string "laborer" starts) in the field value and checking for a value greater than 0. This would mean that "laborer" was found while a value other than a positive integer means that the string "laborer" was not found.
I don't have SSRS installed on this machine to double check so post a comment if you still need help. Also note that IndexOf is case sensitive and that if you want to match to "Laborer" as well, you will have to do a case conversion prior to the IndexOf.
Full expression:
=IIF(Parameters!WLH.Value = CBool("false") AND ReportItems!craft.Value.IndexOf("laborer") >= 0, 0, ---main calculation for the else statement---)
EDIT: To deal with case sensitivity
Use "UCase()" to convert your field to upper case and then test only against "LABORER".
=IIF(Parameters!WLH.Value = CBool("false") AND UCase(ReportItems!craft.Value).IndexOf("LABORER") >=0, 0, ---main calculation for the else statement---)
I have an expression in my report in Report Builder that can have 0 for the sum but when it is displayed it shows "There are Job Reqs at this time." instead of "There are 0 (or 'no') Job Reqs at this time.". How can I get the 0 (or 'no') in this statement?
It's unclear what you are asking, but it sounds like if it is zero, it is actually returning blank. So doing something like this:
=IIF(
ISNOTHING(Fields!MightBeZeroValue.Value) OR
Fields!MightBeZeroValue.Value) = "",
"0",
Fields!MightBeZeroValue.Value)
This means that if the 'MightBeZeroValue' field is null or empty, display zero, otherwise display that field. Hope this helps.
If you can do this within the SQL, then even better:
SELECT
ISNULL(MightBeZeroValue.Value, 0) AS MightBeZeroValue
FROM
SomeTable
I would like to know if i can able to identify activeitem(below code) is available in SapGuiTree in SAP.
code:
SAPGuiSession("guicomponenttype:=12").SAPGuiWindow("guicomponenttype:=21").SAPGuiTree("treetype:=SapColumnTree").ActivateItem "Inbound Monitor;11.05.2016;1111;Sales Movement","Sales Movement"
i tried below method but not worked
if isNull 'code' then
else
statement
end if
Can anyone suggest any method to identy this issue
Thanks in advance.
You can achieve this by checking all the node values under a SAPGuiTree object.
'Set Object
Set TreeObj = SAPGuiSession("a").SAPGuiWindow("b").SAPGuiTree("c").Object
'First you need to get all values under this tree
Set AllValues = TreeObj.GetAllNodeKeys
'Get count
Count = AllValues.Count
'Begin search the value you want
Found = 0
For i = 0 to Count-1
NodeText = TreeObj.GetNodeTextByKey(AllValues(i))
If NodeText = "SearchValue" Then
Found = 1
Exit For
End if
Next
If Found = 1 Then
'Do something
End if
Update1:
You can also use Regular Expression to do a pattern match when searching your desired value under a tree object.
In my code I have a hash, each one with a set value of 0, after running through the code, I would like it to display "1", but it only displays a 0. Can anyone help, and please explain my error and why it didn't work.
puts "Hello!, and welcome to the 'Coin Calculator V1.0', please enter a value."
coin_value = gets.to_i
coin_num = {"quarters" => 0,"dimes" => 0,"nickels" => 0,"pennies" => 0}
if coin_value>25
coin_value-25
coin_num["quarters"]+1 // **basically, how do I add an integer value to the old integer?
puts coin_num["quarters"]
end
coin_num["quarters"] = coin_num["quarters"] + 1
which can be shortened using the += operator (addition assignment):
coin_num["quarters"] += 1
Neither of your arithmetic expressions changes anything.
coin_value - 25
That evaluates to 25 less than coin_value; if you printed it out or assigned it somewhere, you would see that. But since you don't do anything with the value, it just gets thrown away and nothing happens. Certainly, coin_value doesn't change.
Similarly,
coin_num["quarters"] + 1
evaluates to one more than the current value of coin_num["quarters"], but doesn't change anything.
If you want to change the value of a variable - any variable, whether a simple scalar like coin_value or an element of a Hash or Array - you have to use an assignment statement. You need an =, and the variable you want to change has to be on the left hand side of that =:
coin_value = coin_value - 25
coin_num['quarters'] = coin_num['quarters'] + 1
Ruby does define shorthand operators for modifying a variable using a simple expression involving that same variable's previous value:
coin_value -= 25
coin_num['quarters'] += 1
But you're still using = - it's just part of a compound assignment operator now.
I would like something like that :
While Not RdoRst.EOF And RdoRst(2) = "Foo"
cboComboBox.AddItem RdoRst(1)
cboComboBox.ItemData(cboComboBox.NewIndex) = RdoRst(0)
RdoRst.MoveNext
Wend
I want that the expression 1 (Not RdoRst.EOF) is evaluated first. Then if it returns true, the expression 2 is evaluated too (RdoRst(2) = "Foo"). If expression 1 return false, the expression 2 is not evaluated.
Regards,
Florian
AndAlso is not available in VB6. Try this
Do
If RdoRst.EOF Then Exit Do
If Not RdoRst(2) ="Foo" Then Exit Do
cboComboBox.AddItem RdoRst(1)
cboComboBox.ItemData(cboComboBox.NewIndex) = RdoRst(0)
RdoRst.MoveNext
Loop
The question relates to 'short circuit' evaluation of condition expressions. Well VB6 does not support this feature. I know this is stupid.
While Not RdoRst.EOF
If RdoRst(2) = "Foo" Then
cboComboBox.AddItem RdoRst(1)
cboComboBox.ItemData(cboComboBox.NewIndex) = RdoRst(0)
Else
Exit Wend
End If
RdoRst.MoveNext
Wend