Solved

SSRS Expression returning an #Error

Posted on 2013-06-10
3
752 Views
Last Modified: 2013-06-11
Hi, I have this expression in the report header that takes the value from  the first record in the main recordset and pops it into the report title.  The problem is when NO records are returned by the main recordset, I get an error.  

Maybe I've got this all wrong to begin with b/c it assumes records will be returned.  What's the best way to handle no records in my report header expression?

="Total Number of Widgets: " & IIF(IsNothing(First(Fields!NbrOfWidgets.Value, "MainRecordset")), "0", First(Fields!NbrOfWidgets.Value, "MainRecordset").ToString)
0
Comment
Question by:MariaHalt
3 Comments
 
LVL 11

Expert Comment

by:srikanthreddyn143
ID: 39237464
Countrows("dataset") returns you number of rows returned. Make sure that this value is greater than 0 to populate from the first record
0
 
LVL 27

Accepted Solution

by:
planocz earned 500 total points
ID: 39238698
This is what you need...

 ="Total Number of Widgets: " & IIF(CountRows("MainRecordset")=0,"0",(Fields!NbrOfWidgets.Value, "MainRecordset"))
0
 

Author Closing Comment

by:MariaHalt
ID: 39238709
So straightforward, thank you.
0

Featured Post

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

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…
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

863 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now