0

大家早上好,我正在尝试为我正在用 Crystal 编写的报告创建一个公式,该公式以 10,000 为增量按升序对家庭年收入进行分组。到目前为止,我已经遵循了我认为正确的“如果-那么”模式。但是我收到一条错误消息,上面写着“剩余的文本似乎不是公式的一部分”。下面是代码内容: 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"

发生的情况是错误检查器仅突出显示最后 12 行代码。我有点生疏,所以如果有人有任何建议,我将非常感激。

谢谢

4

1 回答 1

0

您需要else在字符串之后包含

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"

您还可以使用 case 语句对其进行一些清理:

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"
;
于 2016-12-16T16:58:35.277 回答