同一列上的SSRS不同数字格式
SSRS different number formats on the same column
我正在尝试格式化 1 列以根据值来设置数字格式:
我现在的table
我试图让它成为一个百分比,除非描述中说的是统一税,然后我希望它成为一种货币。
有什么想法吗?
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
为税额列添加表达式。
=IIF(Fields!Description.Value <> "Flat Tax", FormatPercent(Fields!Tax_Amt.Value,3), FormatNumber(Fields!Tax_Amt,2))
试试这个:
=IIF(Fields!Description.Value="FLAT TAX",
Format(CDBL(Fields!Tax_Amount.Value),"C3"),Format(CDBL(Fields!Tax_Amount.Value),"P2")
)
更新:您似乎从查询中传递了 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
如果有帮助请告诉我。
我正在尝试格式化 1 列以根据值来设置数字格式:
我现在的table
我试图让它成为一个百分比,除非描述中说的是统一税,然后我希望它成为一种货币。
有什么想法吗?
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
为税额列添加表达式。
=IIF(Fields!Description.Value <> "Flat Tax", FormatPercent(Fields!Tax_Amt.Value,3), FormatNumber(Fields!Tax_Amt,2))
试试这个:
=IIF(Fields!Description.Value="FLAT TAX",
Format(CDBL(Fields!Tax_Amount.Value),"C3"),Format(CDBL(Fields!Tax_Amount.Value),"P2")
)
更新:您似乎从查询中传递了 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
如果有帮助请告诉我。