crystal-reports - conditional color formatting based on string and number
问题描述
I am trying to fix the logic in my report where any {nresult} > {flaglevel} =crred. This works except we initially didn't take into account the fact that {flaglevel} defaults to 0 unless a specific number is entered. so ALL {nresult} are red even if {flaglevel} is just the default.
{nresult} is a number and {flaglevel} is a string. The current code is
If {PRM_SxData.nResult} > tonumber({PRM_SxData.FlagLevel})
then crRed
Else crBlack
I tried to make a separate formula for {flaglevel} except I have to have a number after else so it doesn't work.
if tonumber ({PRM_SxData.FlagLevel}) > 0
then tonumber({PRM_SxData.FlagLevel})
else " "
Essentially what I need is something like this:
If {PRM_SxData.nResult} > tonumber({PRM_SxData.FlagLevel}) //where flaglevel >0
then crRed
Else crBlack
解决方案
I am kinda pessimist about user input and i think R.McMillan made a good question, so i would go with something like this:
If (not isnull({PRM_SxData.FlagLevel))
AND {PRM_SxData.FlagLevel} <> ""
AND {PRM_SxData.nResult} > tonumber({PRM_SxData.FlagLevel})
then crRed
Else crBlack
Please, try this and let us know what happened.
If it does not work, print {PRM_SxData.FlagLevel} somewhere to check its value.
推荐阅读
- reactjs - 无法在反应组件中更改 moment.js 的默认语言环境
- r-markdown - R Markdown + bib文件:未使用的参数错误
- python - Mac OS Pycharm 上的 Python 通过“import matplotlib.pyplot as plt”给出框架错误
- swift - 如何从文件 Swift 中读取
- javascript - 无法将缓冲区转换为字符串
- assembly - Tasm:尝试将一个字符串以相反的顺序复制到另一个字符串并使用字符串操作显示它
- django - Gapps 脚本:使用用户身份验证凭据来授权 vs 外部 django 应用服务(使用 google 作为 oauth 提供者)
- python - 如何使 Recaptcha 与 QWebView 一起工作
- java - 使用 Hibernate 对 Enum 类型进行 Java8 Bean 验证
- java - 读取 txt 文件并返回一个包含多个字段的对象数组