Reputation: 13
I need to implement custom sort on SSRS report on a Payment-Range field obtained from one of the dateset
Payment-Range is appearing like this:
$0 - $200
$200.01 - $1000
$1,000.01 - $10,000
$10,000.01 - $20,000
$20,000.01 - $30,000
$30,000.01 - $40,000
$40,000.01 - $50,000
$50,000.01 - $60,000
I have used if else in order to implement
=IIF(Fields!netPaymentRange.Value= "$0 - $200", "A",
IIF(Fields!netPaymentRange.Value= "$200.01 - $1000", "B",
IIF(Fields!netPaymentRange.Value= "$1,000.01 - $10,000", "C",
IIF(Fields!netPaymentRange.Value= "$20,000.01 - $30,000", "D",
IIF(Fields!netPaymentRange.Value= "$30,000.01 - $40,000", "E",
IIF(Fields!netPaymentRange.Value= "$40,000.01 - $50,000", "F",
IIF(Fields!netPaymentRange.Value= "$50,000.01 - $60,000", "G","")))))))
but it is not working for me. Please suggest
Upvotes: 1
Views: 107
Reputation: 3195
I would create a CTE with a select from values query to create the sort order for your list of payment ranges. Then you can join to the source table/view for the report dataset. I would still suggest storing the payment_range
as a table.
WITH
payment_range
AS
(
SELECT tbl.* FROM (VALUES
( '$0 - $200', 1)
, ( '$200.01 - $1000', 2)
, ( '$1,000.01 - $10,000', 3)
, ( '$20,000.01 - $30,000', 4)
, ( '$30,000.01 - $40,000', 5)
, ( '$40,000.01 - $50,000', 6)
, ( '$50,000.01 - $60,000', 7)
) tbl ([netPaymentRange], [netPaymentRangeSortOrder])
)
SELECT
*
FROM
payment_range --join to your source table here
ORDER BY
[netPaymentRangeSortOrder]
Upvotes: 1