Using condition to set SSRS matrix column name

℡╲_俬逩灬. 提交于 2020-01-06 18:09:13

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!