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)
=Sum(Fields!PERCENT_BOOKED
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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]
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).
ASKER
w3
ASKER
ty
ASKER
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.