问题
I'm working in an SSRS 2005 Report Model Project. I want to create an expression field on a ReportModel that does the same as this C# method:
private static int GetClosestWholeNumberToward0(double delta)
{
return (int) (delta > 0 ? Math.Ceiling(delta) : Math.Floor(delta));
}
I tried this:
IF(delta > 0, Ceiling(delta), Floor(delta))
But it seems that ReportModel expressions don't support the Ceiling or Floor functions. Is there a way to do this?
Update: Due to changing requirements that added additional complexity to this report, I'm going to start over with the Report Designer in Visual Studio. So I should be able to use the Math.Ceiling() and Math.Floor() in an expression field on the report.
回答1:
It is in fact supported. Use the following expression:
=IIF(delta > 0, ceiling(delta), floor(delta))
回答2:
If you cannot find an SSRS solution you can of course create a c# assembly and call it from your report!
来源:https://stackoverflow.com/questions/1589423/how-to-use-floor-ceiling-in-a-reportmodel-expression-field