Friday, February 10, 2012

calculated sum

I have a dataset that returns a measure and a bunch of dimensions. What I need to be able to do is calculate a sum of this measure based on one dimension. ie..
Sum(measure) where dimension = "Top". Any ideas on how to accomplish this.No ideas? Seems to be a pretty basic function.|||Do you want the report user to interactively select a dimension value, and have the sum adjusted accordingly? In that case, you could set up a filter on the dataset, where the expression is the dimension column value, the operator is "=" and the value to compare against is the input parameter value.|||Nope. I just want to do a sum based on a dimension. Something like this.

Dataset1

Country Quantity
USA 1
USA 3
CANADA 1
MEXICO 3
CANADA 2

The sysntax I would use in Business Objects would be:

SUM(QUANTITY) WHERE(COUNTRY = "USA")

this expression would return 4.|||

Not sure if this solution will work for you, but you can add a Calculated Field to the Data Set, say: "FilteredQty", defined as (assuming Quantity is an integer):

CInt(iif(Fields!Country.Value = "USA", Fields!Quantity.Value, 0))

Then in your report you can use this expression:

Sum(Fields!FilteredQty.Value), wich should return 4 rather than 10

To make it dynamic, "USA" can be replaced by a report parameter.

|||Beautiful!! Works great. Thank you for your help.

No comments:

Post a Comment