having a small issue here.
I have a Switch
function in a report as shown below:
=Switch(
Fields!Duration.Value > 0, Round(Fields!Duration.Value / 60),
Fields!LastTime.Value = nothing, "Still Occupied",
Fields!LastTime.Value = Fields!FirstTime.Value, "Passing By"
)
This is for a column that is showing the total "Fields!Duration.Value" in minutes (rounded up), and it is working other than the second line:
If the Last Time value is the same as the First Time value, then it is assumed the object was just passing by and outputs "Passing By" and it does this correctly.
However, if the Last Time value is equal to nothing (it is defined in the column for "Last Time" that if it IsNothing, it is 'nothing', and it should output in this report with "Still Occupied" - which it's not doing. The cell is left blank, as if I have it written as Fields!LastTime.Value = nothing, nothing,
Why is this line of code not working?
Fields!LastTime.Value = nothing, "Still Occupied",
Thank you
I found that using an IIF statement instead of a Switch statement worked for me, at least for this specific case:
=IIF(Fields!Duration.Value > 0, Round(Fields!Duration.Value / 60),
IIF(Fields!LastTime.Value = Fields!FirstTime.Value, "Passing by", "Still Occupied"))
Going to try to explain it for future people that might not understand (like me when I eventually forget it - I am very new to this sort of stuff) -
Rather than using the Switch
statement I had in place to see if Fields!LastTime.Value
is a number, equal to Fields!FirstTime.Value, or nothing, it now just asks if it is a number or if it is equal to Fields!FirstTime.Value
, and if neither of those are true, it marks it as "Still Occupied" thus removing the need to reference nothing
entirely. Like I said, this is pretty case specific, but you never know.
Thank you for the help @JamieSee and @SuperSimmer 44. Cheers!