Link to home
Start Free TrialLog in
Avatar of vbnetcoder
vbnetcoder

asked on

sum returns and error if there are no rows

When my dataset does not return any records and i do a sum i get and error.  How do i fix this?

=Sum(Fields!PERCENT_BOOKED.Value)
ASKER CERTIFIED SOLUTION
Avatar of Russell Fox
Russell Fox
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of vbnetcoder
vbnetcoder

ASKER

Russell,

I thought that would work but it didn't.  I think SSRS looks to both sides of the equation and it still errors out on the sum even though it isn't being used.
You mean the entire data set is empty / doesn't exist? You might then need to force the query to always return some sort of value:
IF EXISTS(SELECT 1 FROM YourTable WHERE [SomeField] = 'SomeValue')
SELECT [PERCENT_BOOKED]
FROM YourTable
ELSE
SELECT 0.00 AS [PERCENT_BOOKED]

Open in new window

Many people don't know that you can use more than just a standard select query in the query block on a report. I even have one that does updates before returning a value (hidden parameters passed in through the URL).
w3
ty