Solved

SSRS Expression returning an #Error

Posted on 2013-06-10
3
759 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
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 the fundamental information of how to create a table.

734 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