Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

SSRS IIF & Switch Not behaving

Posted on 2015-01-22
3
Medium Priority
?
391 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 2000 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

971 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