1

I am trying to sum a total where the year is less than the max year.

=Sum(iif(Fields!YEAR.value < max(Fields!YEAR.value), Fields!Year_Sold.Value,0)) 

it runs but i am getting #ERROR is my syntax correct?

2 Answers 2

1

Try adding the dataset for the MAX - aggregate functions require the dataset so they get the max over the whole dataset and not the one record.

=Sum(IIF(Fields!YEAR.value < MAX(Fields!YEAR.value, "Dataset1"), Fields!Year_Sold.Value, 0)) 
Sign up to request clarification or add additional context in comments.

9 Comments

I tried your suggestion and I'm still getting the #ERROR.
Are you using BIDS (Visual Studio shell)? If so, are you getting any warnings in the Error List or the Output window?
I'm using report builder 3.o.
What is the data type of Year Sold? I was assuming INTEGER. If it's a decimal , try using CDEC(0) instead of 0. On another note, is that the right column - you're adding up your Year_Sold field?
Year_sold represent the number of items sold. and it is an integer
|
0

I got it to work by replacing the 0 with Nothing so here is what worked for me =Sum(iif(Fields!YEAR.Value < Parameters!EndYear.Value, Fields!Year_Sold.Value, Nothing))

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.