Solved

SSRS IIF & Switch Not behaving

Posted on 2015-01-22
3
275 Views
Last Modified: 2015-01-22
I am working on a SSRS Report that looks at attendance. I am calculating how many minutes an employee is from clocking in verses the time he/she is supposed to be clocking in.  Our rule is, if you are more than 5 minutes from when you are supposed to clock in, you are late.  If you are more than 5 minutes before, you are early.  Anything and everything in between is considered on time.  Example:  Employee has a start time of 9AM. they punch in at 9:06, that would be considered late.  they clock in at 8:57, that is considered on time.  They clock in at 8:54, that is considered early.

So, I am looking at this Time difference and attempting to make SSRS return the "early, late, on time" flag.

This:

=iif(Fields!Time_Diff.Value > 5, "LATE","EARLY")   This statement will give me all of the lates, and defaults everything else to early.

 So, I then decided I need a SWITCH statement to look for the on time ones:

=Switch(Fields!Time_Diff.Value > 5, "Late",
Fields!Time_Diff.Value <  -5, "Early",
"On Time")

When I do that, I get "#ERROR" returned for all values.  Am I doing something wrong with the switch?  That syntax looks correct to me.
0
Comment
Question by:sbalawajder
  • 2
3 Comments
 
LVL 24

Expert Comment

by:Phillip Burton
ID: 40565168
Yes, the syntax is wrong. You can't use SWITCH like that.

Have a look at the function syntax https://msdn.microsoft.com/en-us/library/gg492166.aspx

It means you need your field as the first argument, then the first possible value as the second, then the first possible answer as the third.
0
 
LVL 24

Accepted Solution

by:
Phillip Burton earned 500 total points
ID: 40565171
Why not use

iif(Fields!Time_Diff.Value > 5, "LATE", iif(Fields!Time_Diff.Value <-5, "EARLY", "On time"))
0
 

Author Comment

by:sbalawajder
ID: 40565196
That IIF worked!  Thanks...I didn't realize you could do an IIF like that.

Also- thanks for the clarification on the SWITCH
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question