Solved

SSRS Expression returning an #Error

Posted on 2013-06-10
3
758 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Conditions in Where clause 9 46
SQL Pivot table 2 42
Need time in SQL 8 30
Need help separating values from a column and creating a new record 6 41
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
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…

740 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