Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7
This is the forum to discuss the Wrox book Professional SQL ServerReporting Services by Paul Turley, Todd Bryant, James Counihan, George McKee, Dave DuVarney; ISBN: 9780764568787
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old August 24th, 2005, 08:35 PM
Authorized User
 
Join Date: Aug 2004
Location: , , .
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to barmanvarn
Default iff statement not working

I have the following statement:

=iif( Fields!Ticket_Budget.Value = 0,0, Fields!Ticket_Sales.Value/Fields!Ticket_Budget.Value)

For some reason, it keeps trying to divide by zero when the budget fields IS equal to zero.

Any suggestions?
  #2 (permalink)  
Old October 3rd, 2005, 12:12 PM
Authorized User
 
Join Date: Dec 2004
Location: Phoenix, AZ, USA.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to bsullins
Default

This is one of the major PITA's in Reporting Services...

Reporting Services evaluates every part of the if statement so you have to do a nested if that evaluates to 1 if the value of ur field is 0.

Like so...

=iif(Fields!Ticket_Budget.Value=0,0,iif(Fields!Tic ket_Budget.Value=0,1,Fields!Ticket_Sales.Value/Fields!Ticket_Budget.Value))

Try that...

--
Ben Sullins
Sql Developer - Our Vacation Store
  #3 (permalink)  
Old January 23rd, 2009, 04:58 AM
Registered User
 
Join Date: Jan 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Smile hi


example1:
=Switch( Fields!QtyTobeFilled.Value<= Fields!QuantityOnHand.Value,"Green",
Fields!QtyTobeFilled.Value>Fields!QuantityOnHand.V alue,"Blue")

example2:
iif(Fields!QtyTobeFilled.Value<= Fields!QuantityOnHand.Value,"Green",iif(Fields!Qty TobeFilled.Value>Fields!QuantityOnHand.Value,"Red" ))
  #4 (permalink)  
Old January 23rd, 2009, 03:25 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,652
Thanks: 3
Thanked 141 Times in 140 Posts
Default

Quote:
Originally Posted by bsullins View Post
Reporting Services evaluates every part of the if statement so you have to do a nested if that evaluates to 1 if the value of ur field is 0.

=iif(Fields!Ticket_Budget.Value=0,0,iif(Fields!Tic ket_Budget.Value=0,1,Fields!Ticket_Sales.Value/Fields!Ticket_Budget.Value))
Ummm...how does that fix the problem??? You *STILL* end up doing a divide by zero if *ALL* parts of *ALL* IIF's are evaluated.

I think you just made a typo. I think you meant to write:
Code:
=iif(Fields!Ticket_Budget.Value=0, 0,
     Fields!Ticket_Sales.Value / iif(Fields!Ticket_Budget.Value=0,1,Fields!Ticket_Budget.Value)
)
That way, if the value *IS* zero, you change it to 1 so no "divisiion by zero". But then the prior IIF ends up ignoring the division quotient, anyway, so the divide by 1 has no impact.

You *COULD* also do
Code:
= ( Fields!Ticket_Sales.Value / iif(Fields!Ticket_Budget.Value=0,1E100,Fields!Ticket_Budget.Value) )
So that the quotient becomes a really tiny number and, when displayed, will show as zero. Don't do this if you will use the result in any further calculation, but it should work for display-only purposes.
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
IFF statement in SQL scott.allison@slp-eng.com SQL Server 2000 1 January 15th, 2007 12:13 PM
Would this be a IFF then Statement Corey Access 7 November 2nd, 2006 02:18 PM
Simple but not working IF THEN statement nlicata Classic ASP Databases 6 June 6th, 2003 10:26 AM



All times are GMT -4. The time now is 11:59 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.