简体   繁体   English

SSRS报表生成器:根据文本框值创建文本颜色表达式?

[英]SSRS Report Builder: Creating text color expression based on textbox value?

Is it possible to have SSRS look at the value of a text box after calculating it, and then apply an expression to determine the color of the text? 是否可以让SSRS在计算后查看文本框的值,然后应用表达式来确定文本的颜色?

More specifically, I have a lot of different text boxes that contain custom formulas to calculate percentages. 更具体地说,我有很多不同的文本框,其中包含用于计算百分比的自定义公式。 Normally, I would create an IIF statement in the text color expression builder like this: 通常,我会在文本颜色表达式构建器中创建一个IIF语句,如下所示:

IIF([complex formula]<0,"RED","GREEN"). 

This works fine, but when you have a ton of these textboxes, each with different formulas, it would be much more efficient to just copy one standard color expression into them like this: 这样可以正常工作,但是当你有大量的这些文本框,每个文本框都有不同的公式时,将一个标准颜色表达式复制到它们中会更加高效,如下所示:

IIF(This.Value>0,"RED","GREEN")

Are expressions like this possible in SSRS? 在SSRS中这样的表达是否可行?

The answer is yes, if you are using a very recent version of SSRS: 答案是肯定的,如果您使用的是最新版本的SSRS:

=IIF(Me.Value < 0,"Red","Green")

Link to original article here 链接到原始文章在这里

Hope that helps. 希望有所帮助。

It's not as clean, but if you need to refer to a different already calculated cell (or self reference for that matter) you can use 它不是那么干净,但是如果你需要引用一个不同的已经计算的单元格(或者那个问题的自我引用),你可以使用它

=IIF(ReportItems!CellName.Value < 0,"Red","Green")

EDIT: This is actually listed in the link @Randall Mathews posted, which I didn't click until I answered. 编辑:这实际上是在@Randall Mathews发布的链接中列出的,在我回答之前我没有点击。

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

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