Minimize
17

 

I recently had a report that ran fine with no error and then we reprocessed the cube with a different data source and the report had many cells displaying #Error. After playing with it for a while I noticed that it was also getting a warning message “This field is missing from the returned result set form the data source. The columns displaying errors were the ones reference in the error message and had a value derived by an expression to replace nulls with 0, something like Iif(Field!MTD_Incident_Count.Value is nothing,0,Field.MTD_Incident_Count.Value). 
 
It turns out the problem is caused by the way Analysis Services(SSAS) data provider and SSRS handle a column in a result set that has nulls in every row. What the SSAS data provider does is not send the column down to the client because the value in every row is null. What that means is you cannot even check the field!MTD_Incident_Count.Value in any way because it does not exist in the result set so the Value method on the fields object will give an exception if reference in anyway.
 
When the report runs you see the warning about fields missing in result set.
 
[rsMissingFieldInDataSet] The dataset ‘Dataset1’ contains a definition for the Field ‘MTD_Incident_Count’. This field is missing from the returned result set from the data source.
[rsErrorReadingDataSetField] The dataset ‘Dataset1’ contains a definition for the Field ‘MTD_Incident_Count’. The data extension returned an error during reading the field. There is no data for the field at position 4.
 
You only get this warning if the value of every row for a column is null. The way to fix this is to change the expression that is used to replace the null with 0.
 
First we must create a report function (Code tab in Report Properties dialog) that can look at the IsMissing field property before it looks at the Value property.   An Immediate If (IIF) statement cannot be used because all parts of the statement are evaluated which causes an exception.
 
Here is an example of the function to add. We may need multiple versions if the data type it returns need to change.
 
    'If a column in a AS resultset contains all nulls. It is dropped from the dataset so you
    'cannot reference the value field in any way so IsNothing(Field!A.Value) will throw an
    'exception. In order to get around this error you can define a function to in the report
    'you can define a function to check if the field is missing before checking for nulls
 
    Function NullAsZero(ByRef F As Field) As Double
        If F.IsMissing Then
            Return 0
        Else
            If F.Value Is Nothing Then
                Return 0
            Else
                Return F.Value
            End If
        End If
    End Function

 

The Report Properties Dialog is used to add the function.

 

Next you need to replace the expression used on the report cell Iif(field!MTD_Incident_Count.Value is nothing,0,field.MTD_Incident_Count.Value) with something like this Code.NullAsZero(Fields!MTD_Incident_Count).

 Expression Dialog - NullAsZero Sample

And finally notice the NullAsZero returns a double which provides the most flexible numeric result but it must be formatted to what you want. Use the TextBox Properties Dialog Number tab to get it to display correctly, with the number of decimal places as needed.

 

Text Box Properties

 

This problem was very aggravating and I hope this entry will help someone keep their sanity.

Comments

There are currently no comments, be the first to post one.

Post Comment

Only registered users may post comments.

LatestArticles Minimize
Changing Granularity of Leaf Level Calculations in SSAS Tabular by Jason Thomas

Finding Nearest Stores using SSRS Map Reports by Jason Thomas

Heat Maps for SSRS using Map Control by Jason Thomas

Parameters for Analysis Services Reporting: Introduction, Pt. 3 by William Pearson
BI Architect Bill Pearson continues an extended examination of parameterization within Analysis Services reports. In this, Part 3 of the article, we continue to get hands-on practice cr...

Parameters for Analysis Services Reporting: Introduction, Pt. 2 by William Pearson
BI Architect Bill Pearson continues an extended examination of parameterization within Analysis Services reports. In this, Part 2 of the article, we continue to get hands-on practice cr...

Using Annotation Tables in SSAS to Show Last Processed Time and Latest Data Updates as a Measure in a Cube by John Hall

Using Color in SSRS Charts by Melissa Coates
Effective data presentation techniques help users  interpret information quickly and reliably.  Layout, formatting, sizing, labeling, and other report elements may all be used to facilitate ...

Is TOAD faster than BIDS Query Builder? by John Hall

SSRS: Unexplained Warning “This field is missing from the returned result set from the data source” And Checking a Field for Null Exception by John Hall
If you ever see the warning message “This field is missing from the returned result set form the data source” and get unexplained #Errors in columns on your report it may be from SSAS not returning a ...

Beyond Excel pivot tables: Leveraging cube formulas with MDX by Javier Guillen
PowerPivot and DAX are a powerful technologies, but there is still a good amount of work that can be done with traditional cube functions. In its current version, PowerPivot lacks the concept of ...


Advertisement Minimize

Advertisement Minimize

Copyright 2004-2012 MSBICentral.com Terms Of Use Privacy Statement