Solved

SSRS Expression returning an #Error

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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
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…
Viewers will learn how the fundamental information of how to create a table.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

696 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