Crystal Report,根据Criteria将行分组为单行

时间:2014-04-03 09:21:21

标签: crystal-reports

我有一份水晶报告,根据Fruit Name Group显示不同的水果数据。

我附加了一个屏幕截图,告诉了明确的要求,我想将相同类型的水果合并为一行,并将它们的值合并。

我需要帮助,有人可以提出更好的建议吗? Screenshot

3 个答案:

答案 0 :(得分:1)

I am  not able to understand completely you problem.. but try below solution: If it is useful use it else discard

连接水果名称:创建一个公式@Fruit

Local StringVar orange;
Local StringVar Lemon;
Local StringVar Grape;

if <<databasefield.fruitname>>="Orange"
then orange:=<<databasefield.fruitname>>
else if <<databasefield.fruitname>>="Lemon"
then Lemon:=<<databasefield.fruitname>>
else  if <<databasefield.fruitname>>="Grape"
then Grape:=<<databasefield.fruitname>>;
orange+Lemon+Grape;

汇总值:创建一个公式@Weight

Local NumberVar orange;
    Local NumberVar Lemon;
    Local NumberVar Grape;

    if <<databasefield.fruitname>>="Orange"
    then orange:=<<databasefield.Weight>>
    else if <<databasefield.fruitname>>="Lemon"
    then Lemon:=<<databasefield.Weight>>
    else  if <<databasefield.fruitname>>="Grape"
    then Grape:=<<databasefield.Weight>>;
    orange+Lemon+Grape;

编辑:--------------------------------------------- --------------------------------------- 你需要对下面的内容进行分组。

Fruit name  Fruit Type
Orange       a
Grape        a
peach        b
apples       c

现在当您按fruit type分组并应用我提供的公式时,您可以获得所需的结果

答案 1 :(得分:1)

1)添加Formula Field

此公式字段应返回
   - 对于您不想分组的案例,真实FruitName
   - 您想要组合在一起的行的假FruitName

像这样(拖放字段到公式编辑器中):

if {commandname.FruitName} <> 'Orange' AND  FruitName <> 'Lemon' 
   AND  FruitName <> 'Grape Friut' then  {commandname.FruitName}
else   'Orange, Lemon, Grape Friut'

2)使用Group Expert根据新的Formula Field

创建群组

3)取消详情并在每个字段的Group HeaderGroup Footer Totals中显示

答案 2 :(得分:1)

我已用其他方式完成,将这些水果值计算为一个单独的行,总结所有值然后应用union,在union中我使用COALESCE函数连接水果名称

相关问题