问题描述
我会在报告中说明这些表达方式是否有效。问题是它们不能一起工作。我目前有一个基于两列值格式化的列标题。基于Column1的值,斜体和下划线。 Bold和基于Column2的值的特定颜色。我在文本属性中使用Switch表达式来做到这一点。这是我每个人都有的:
= Switch(Fields!Column1.Value<>具体值斜体,Fields!Column1.Value =Specific Value,Normal)
= Switch(Fields!Column1.Value<"具体值,Underline,Fields!Column1.Value =特定值,无)
= Switch(Fields!Column2.Value< = 7,ExtraBold,Fields!Column2.Value> =`8,Normal)
= (Fields!Column2.Value< = 7,Red,Fields!Column2.Value> = 8,#586d7f)
并显示一张图片,标有:
当我运行报告时,没有错误。
奇怪的是(至少对我来说)结果应该是这样:
- 正常
- 粗体和红色
- 斜体和下划线
- 所有四个 (粗体,斜体,红色和下划线)
在这种情况下,文本应该看起来像4,它看起来像2.所有其他的工作是如何应该是这样我有点困惑,并想要解释为什么这是案件。我看了看是否已经回答过,但是根据我看到的似乎不是这样。如果我使用任何错误的术语,我很抱歉(我对此很新)。
我会使用一个IIF )语句。
= IIF(Fields!Column1.Value<>具体值,斜体,普通)
一般来说,交换机是多个发生的case语句,而IIF语句是典型的if ,那么else else语句。危险就是你可以嵌套IIF语句,如IIF(东西,'set1',iif(thing2,'set2','default')),但是更容易做一个像Switch(thing,'set1,thing2, 'set2','default')。交换机的问题是如果一件事情发生的事情发生,另一个事情发生,那么它假定第一个是真的,只是执行它。因此,你必须考虑事情发生的正确顺序,否则将会承担一切。通常当你有一个事情的实例和一个默认我使用IIF。如果交换机出现问题,我将一般做一个嵌套的IIF或重新排序Switch语句的事件。
我希望有一点帮助。 >
I will open this up by stating that the expressions do work within the report. The problem is they aren't working together.
I currently have a column header formatted based on the values of two columns. Italics and underlined based on the value of Column1. Bold and a specific color based on the value of Column2. I am doing this by using Switch expressions in the text properties. Here is what I have for each:
=Switch(Fields!Column1.Value <> "Specific Value","Italic",Fields!Column1.Value = "Specific Value","Normal")
=Switch(Fields!Column1.Value <> "Specific Value","Underline",Fields!Column1.Value = "Specific Value","None")
=Switch(Fields!Column2.Value <= 7,"ExtraBold",Fields!Column2.Value >=` 8,"Normal")
=Switch(Fields!Column2.Value <= 7, "Red",Fields!Column2.Value >= 8,"#586d7f")
And an image to show they are all marked:
When I run the report there are no errors.
The odd thing (to me at least) is the results should look like this:
- Normal
- Bold and red
- Italics and underlined
- All four (Bold, Italics, red, and underlined)
In a situation where the text should look like 4 it looks like 2. Everything else is working how it is supposed to so I am a bit stumped and would like an explanation for why this is the case. I looked to see if this had been answered before, but based on what I saw it doesn't seem like it. If I used any of the wrong terminology I apologize (I am pretty new to this).
I would use an IIF() statement instead.
=IIF(Fields!Column1.Value <> "Specific Value", "Italic", "Normal")
Generally speaking a switch is a 'case' statement for multiple occurences and an IIF statement is a typical 'if, then, else' statement. The danger becomes that you can nest IIF statements like IIF(thing, 'set1', iif(thing2, 'set2', 'default')) but it would be easier to do a switch like Switch(thing, 'set1, thing2, 'set2', 'default'). The problem with switches is if an occurence of something happens of both one thing and another it assumes the first is true and just performs that. Thus you must account for proper order of something's occurence or it will assume the first instance. Generally when you have an instance of something and a default I use IIF. If there is a problem with a switch I will do a nested IIF generally or reorder the events of the Switch statement.
I hope that helps a little bit.
这篇关于SSRS - 条件文本格式(使用开关的表达式)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!