Creating formula to display group income in ascending order in Crystal Reports

144 Views Asked by At

Good morning everyone, I'm trying to create a formula for a report I'm writing in Crystal that groups annual household incomes in increments of 10,000 in ascending order. So far I've followed what I'd believed to be the proper "if-then" pattern. But I'm getting an error that reads "The remaining text does not appear to be part of the formula." Here is the code content: crAscendingOrder if{ss_client_data_set.income}< 10001 then "$0 to $10,000" if{ss_client_data_set.income}< 20001.00 then "$10,001 to $20,000" if{ss_client_data_set.income}< 30001.00 then "$20,001 to $30,000" if{ss_client_data_set.income}< 40001.00 then "$30,001 to $40,000" if{ss_client_data_set.income}< 50001.00 then "$40,001 to $50,000" if{ss_client_data_set.income}< 60001.00 then "$50,001 to $60,000" if{ss_client_data_set.income}< 70001.00 then "$60,001 to $70,000" if{ss_client_data_set.income}< 80001.00 then "$70,001 to $80,000" if{ss_client_data_set.income}< 90001.00 then "$80,001 to $90,000" if{ss_client_data_set.income}< 100001.00 then "$90,001 to $100,000" if{ss_client_data_set.income}< 110001.00 then "$100,001 to $110,000" if{ss_client_data_set.income}< 120001.00 then "$110,001 to $120,000" if{ss_client_data_set.income}< 130001.00 then "$130,000 and over"

What happens is the error checker only highlights the last 12 lines of code. I'm a bit rusty so if anyone has any advice I'd very much appreciate it.

Thank you

1

There are 1 best solutions below

4
Justin Woodmancy On

You need to inclue else after the strings

if{ss_client_data_set.income}< 10001 then "$0 to $10,000" else
if{ss_client_data_set.income}< 20001.00 then "$10,001 to $20,000" else
if{ss_client_data_set.income}< 30001.00 then "$20,001 to $30,000" else
if{ss_client_data_set.income}< 40001.00 then "$30,001 to $40,000" else
if{ss_client_data_set.income}< 50001.00 then "$40,001 to $50,000" else
if{ss_client_data_set.income}< 60001.00 then "$50,001 to $60,000" else
if{ss_client_data_set.income}< 70001.00 then "$60,001 to $70,000" else
if{ss_client_data_set.income}< 80001.00 then "$70,001 to $80,000" else
if{ss_client_data_set.income}< 90001.00 then "$80,001 to $90,000" else
if{ss_client_data_set.income}< 100001.00 then "$90,001 to $100,000" else
if{ss_client_data_set.income}< 110001.00 then "$100,001 to $110,000" else
if{ss_client_data_set.income}< 120001.00 then "$110,001 to $120,000" else
if{ss_client_data_set.income}< 130001.00 then "$130,000 and over"

You could also use a case statement to clean it up a bit:

Select {ss_client_data_set.income}
Case is < 10001: "$0 to $10,000"
Case is < 20001.00: $10,001 to $20,000"
etc...
etc...
default: "doesn't fall within range"
;