Question

A shared data set returns two columns: DaysEarly and NumberShipped. I want to use this in a table to show the number of shipments that were early, on time, and late. The data looks like this:

DaysEarly   NumberShipped
3           123
2           234
1           254
0           542 -- On time shipments
-1          43
-2          13

The table uses this dataset. I have the following expressions:

-- Early kits
=IIf(Fields!DaysEarly.Value > 0, Sum(Fields!NumberOfKits.Value),Nothing)

-- On Time Kits
=IIf(Fields!DaysEarly.Value = 0, Sum(Fields!NumberOfKits.Value), Nothing)

-- Late Kits
=IIf(Fields!DaysEarly.Value < 0, Sum(Fields!NumberOfKits.Value), Nothing)

The last expression sums all shipments. The first two return the following message:

The Value expression for the textrun...contains an error: 
The query returned now rows for the dataset. The expression 
therefore evaluates to null.

What is the correct way to do this? I am looking for a result like this based on the data above:

Early shipments:   611
On time shipments: 542
Late shipments:    56
Was it helpful?

Solution

You were on the right track, you need to move the IIf expression inside the Sum expression:

Early:

=Sum(IIf(Fields!DaysEarly.Value > 0, Fields!NumberShipped.Value, Nothing))

On Time:

=Sum(IIf(Fields!DaysEarly.Value = 0, Fields!NumberShipped.Value, Nothing))

Late:

=Sum(IIf(Fields!DaysEarly.Value < 0, Fields!NumberShipped.Value, Nothing))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top