[英]Convert Negative Values to Zero in SSRS
How would I convert a negative value to be zero in SSRS when designing a report? 设计报告时,如何在SSRS中将负值转换为零?
Example in preview: -2
Outcome in preview: 0, but actually mean 0
I am able to select the textbox where the "-2" is and format its properties to display as "0", but the value behind that "0" is still "-2". 我可以选择“ -2”所在的文本框,并设置其属性的格式以显示为“ 0”,但该“ 0”后面的值仍为“ -2”。 I need the "0" to actually be a value of "0".
我需要将“ 0”实际设置为“ 0”。
Use expression, eg 使用表达式,例如
=IIF(Fields!YourField.Value < 0, 0, Fields!YourField.Value)
For your specific example: 对于您的特定示例:
=IIF(Fields!NetDischarges.Value < Fields!ApptKeptWithin7days.Value, 0, Fields!NetDischarges.Value-Fields!ApptKeptWithin7days.Value)
You can modify your query to return the date difference as a calculated field like so: 您可以修改查询以将日期差作为计算字段返回,如下所示:
SELECT NetDischarges, ApptKeptWithin7days,
CASE WHEN NetDischarges < ApptKeptWithin7days THEN 0 ELSE NetDischarges - ApptKeptWithin7days END AS DaysDifference
FROM MyTable
Then use the DaysDifference
field in your table. 然后在表中使用
DaysDifference
字段。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.