简体   繁体   English

SSRS 表达式中的 LAST WHERE 子句

[英]LAST WHERE clause in SSRS expression

For the visibility of some fields, i want to check if a field has a specific value.对于某些字段的可见性,我想检查一个字段是否具有特定值。

Right now i'm using this visibility expression:现在我正在使用这个可见性表达式:

=IIF (Sum(IIF(Fields!TagName.Value = "Option1" , Fields!Val.Value, 0), "ParamDataset") > 0, true, false)

If option1 is 1, the field is shown, if its 0 then its hidden.如果 option1 为 1,则显示该字段,如果为 0,则隐藏该字段。

Its working, but the solution is bad.它的工作原理,但解决方案很糟糕。 It checks all the entrys of Option1, and if it were at one time 1, the field is shown, even if the last entry is 0. Also it differentiates only between 0 and 1.它检查 Option1 的所有条目,如果一次是 1,则显示该字段,即使最后一个条目是 0。它也仅区分 0 和 1。

I'm searching for a expression which checks only the last entry of "Option1", and if possible also if the value is a specific value, not only 0 or 1. For example if its 23 or whatever.我正在搜索一个表达式,它只检查“Option1”的最后一个条目,如果可能的话,还检查该值是否是特定值,而不仅仅是 0 或 1。例如,如果它是 23 或其他什么。

PS: i cannot use tablix and the corresponding filters, because the process data is in a different dataset than the configuration data. PS:我不能使用 tablix 和相应的过滤器,因为过程数据与配置数据位于不同的数据集中。

I don't think this is possible in an SSRS expression.我认为这在 SSRS 表达式中是不可能的。 I thought of using LAST but you want the LAST where OPTION = 1.我想过使用 LAST,但您想要 OPTION = 1 的 LAST。

You might be able to make it work if you could sort the data so that Option1 is the last sorted followed by your current sorting:如果您可以对数据进行排序,则 Option1 是最后一个排序的,然后是当前排序的,那么您可能能够使其工作:

ORDER BY CASE WHEN TagName = 'Option1' THEN 1 ELSE 2 END, <CURRENT SORT CRITERIA>

Now since your Option 1 TagName is last and you want the last of the Option1, you could use LAST:现在,由于您的 Option 1 TagName 是最后一个并且您想要 Option1 的最后一个,您可以使用 LAST:

=IIF(LAST(Fields!Val.Value, "ParamDataset") > 0, true, false)

It would work better if you could add a ROW_NUMBER to the ParamDataset:如果您可以在 ParamDataset 中添加 ROW_NUMBER,效果会更好:

,ROW_NUMBER()OVER(PARTITION BY TagName ORDER BY SOME_FIELD DESC) ROW_NUM

Then you could check for Tag Name = Option1 and ROW_NUM = 1:然后你可以检查 Tag Name = Option1 和 ROW_NUM = 1:

=IIF(SUM(IIF(Fields!TagName.Value = "Option1" AND ROW_NUM = 1, Fields!Val.Value, 0), "ParamDataset") > 0, true, false)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM