四舍五入到Crsytal报告中的多个位置

时间:2018-10-03 16:43:52

标签: crystal-reports

我不知道是否可以在Crystal报表上执行此操作。我所拥有的是如何根据结果落在哪里报告结果的列表。因此,如果结果(原始数据)为1.63,那么我必须将其四舍五入到最接近的0.1,这样它将是1.6。 这是列表:

0-1.0 round to nearest 0.05
1-10 round to nearest 0.1
10-40 round to nearest 1
40-100 round to nearest 5
100-400 round to nearest 10
400-1000 round to nearest 50
1000+ round to nearest 100

我认为使用上限/下限是可行的,但我不知道自己在做什么错,因为那之后要求使用布尔值。这是我尝试使用的公式。我们的系统使用一种舍入形式,因此我们希望使用该报告来解决舍入问题。

If ({PRM_SxData.nResult} in 0 to 1.0 )
then (Ceiling ({PRM_SxData.nResult}, 0.05)) and (Floor   
({PRM_SxData.nResult}, 0.05))
else 
IF {PRM_SxData.nResult} in 1.01 to 10
then ((Ceiling ({PRM_SxData.nResult}, 0.1)) and (Floor 
({PRM_SxData.nResult}, 0.1)))
else
IF {PRM_SxData.nResult} in 10.01 to 40
then ((Ceiling ({PRM_SxData.nResult}, 1)) and (Floor ({PRM_SxData.nResult}, 
1)))
else
IF {PRM_SxData.nResult} in 40.01 to 100
then ((Ceiling ({PRM_SxData.nResult}, 5)) and (Floor ({PRM_SxData.nResult}, 
5))) 
else
IF {PRM_SxData.nResult} in 100.01 to 400
then ((Ceiling ({PRM_SxData.nResult}, 10)) and (Floor ({PRM_SxData.nResult}, 
10)))
else
IF {PRM_SxData.nResult} in 400.01 to 1000
then ((Ceiling ({PRM_SxData.nResult}, 50)) and (Floor ({PRM_SxData.nResult}, 
50)))
else 
IF {PRM_SxData.nResult} > 1000.01
then ((Ceiling ({PRM_SxData.nResult}, 100)) and (Floor 
({PRM_SxData.nResult}, 100)))
else " "

这很杂乱,但这是我能想到的最好的。

1 个答案:

答案 0 :(得分:0)

尝试一下:

If ({PRM_SxData.nResult} >= 0 and {PRM_SxData.nResult}<= 1.0 )
then Floor({PRM_SxData.nResult}, 0.05)
else 
IF {{PRM_SxData.nResult} >= in 1.01 and {PRM_SxData.nResult} <= 10
then Floor ({PRM_SxData.nResult}, 0.1)
else
IF {PRM_SxData.nResult} >= 10.01 and {PRM_SxData.nResult} <= 40
then Floor ({PRM_SxData.nResult}, 1)
else
IF {PRM_SxData.nResult} >= 40.01 and {PRM_SxData.nResult} <= 100
then Floor ({PRM_SxData.nResult}, 5) 
else
IF {PRM_SxData.nResult} >= 100.01 and {PRM_SxData.nResult} <= 400
then Floor ({PRM_SxData.nResult}, 10)
else
IF {PRM_SxData.nResult} >= 400.01 and {PRM_SxData.nResult} <= 1000
then Floor ({PRM_SxData.nResult}, 50)
else 
IF {PRM_SxData.nResult} >= 1000.01
then Floor ({PRM_SxData.nResult}, 100)
else 0