SSRS在同一列上的不同数字格式

时间:2016-11-09 20:36:35

标签: reporting-services ssrs-2008-r2

我正在尝试使用格式1列来获得基于值的数字格式:

我目前的表格 enter image description here

我试图让它成为一个百分比,除非描述说平税,然后我希望它是一种货币。

有什么想法吗?

SELECT t1.property, '100' AS tran_code, 'ROOM RATE' AS description, NULL AS tax_amt, @rate AS amount
    FROM z_taxtype_detail t1 INNER JOIN z_trancode t2 ON t1.tran_code = t2.code
        WHERE t1.tax_type = 'ROTX'
        AND t1.property = @property
            GROUP BY t1.property
UNION ALL
SELECT t1.property, t2.code, t2.description, (t1.tax_amt / 100),
      (CASE WHEN t1.tax_base = '1' THEN @rate * (t1.tax_amt / 100)
            WHEN t1.tax_base = '4' THEN t1.tax_amt ELSE 0 END) AS tax_amt
    FROM z_taxtype_detail t1 INNER JOIN z_trancode t2 ON t1.tran_code = t2.code
        WHERE t1.tax_type = 'ROTX'
        AND t1.property = @property

2 个答案:

答案 0 :(得分:0)

为Tax Amount列添加表达式。

=IIF(Fields!Description.Value <> "Flat Tax", FormatPercent(Fields!Tax_Amt.Value,3), FormatNumber(Fields!Tax_Amt,2))

答案 1 :(得分:0)

试试这个:

=IIF(Fields!Description.Value="FLAT TAX",
Format(CDBL(Fields!Tax_Amount.Value),"C3"),Format(CDBL(Fields!Tax_Amount.Value),"P2")
)

UPDATE:您似乎从查询中传递了一个NULL值,这可能会在计算表达式时导致错误。

尝试使用此查询:

SELECT t1.property, '100' AS tran_code, 'ROOM RATE' AS description, 0 AS tax_amt, @rate AS amount
    FROM z_taxtype_detail t1 INNER JOIN z_trancode t2 ON t1.tran_code = t2.code
        WHERE t1.tax_type = 'ROTX'
        AND t1.property = @property
            GROUP BY t1.property
UNION ALL
SELECT t1.property, t2.code, t2.description, (t1.tax_amt / 100),
      (CASE WHEN t1.tax_base = '1' THEN @rate * (t1.tax_amt / 100)
            WHEN t1.tax_base = '4' THEN t1.tax_amt ELSE 0 END) AS tax_amt
    FROM z_taxtype_detail t1 INNER JOIN z_trancode t2 ON t1.tran_code = t2.code
        WHERE t1.tax_type = 'ROTX'
        AND t1.property = @property

如果有帮助,请告诉我。