问题
I was trying something new, using matrix and only want to see the recent two years and i made 2 columns. The first column had this expression '=MAX(Fields!Year.Value)-1' and the second column has the expression '=MAX(Fields!Year.Value)'. I expected to only see 2 year columns but it shows all of them and on the last column it sums up all the orders. See the photos below:
In the design view my matrix looks like this:
The output in report is:
The problem is that year 2007 only exists in another year and month, but i dont know why it shows up here. see the image next to see the original data.
The original data is:
And I just want to see the recent 2 years and ignore the rest of the years, like follows:
Thanks in advance.
回答1:
You are adding each year order, instead you have to add only those that correspond to your column year. For previous last year you have to sum only its orders values.
Use these expressions to Sum
only the two recent years orders:
Previous last year:
=Sum(
iif(Fields!Year.Value=Max(Fields!Year.Value)-1,Fields!Total_Ord.Value,0)
)
Last year:
=Sum(
IIF(Fields!Year.Value=MAX(Fields!Year.Value),Fields!Total_Ord.Value,0)
)
UPDATE: Don't group by year and just add two columns under the Month
column group.
This is the matrix you should have:
It will preview:
Let me know if this can help you.
来源:https://stackoverflow.com/questions/33896120/using-condition-to-set-ssrs-matrix-column-name