如何动态删除交叉表列

时间:2014-10-22 08:52:21

标签: postgresql jasper-reports collapse crosstab

序言:我有以下交叉表:

  • 行组:月份,从1月到12月;
  • 列组:名称;
  • 列总数和行总数。

它实际上显示了数据库中每个人在参数年度中花费的总金额。 我的数据源是一个Postgres数据库,我用查询检索数据。

在我的数据库中,我使用了一些"空白"记录,部分提取:因为我需要显示所有月份,并且我在5月份运行此操作,我将需要在1月到12月之间显示。

我的数据库看起来像这样:

  ID  |  NAME  |  MONTH     |  YEAR  |  MONEY  
   1  |  Marco |  January   |  2014  |  150.0
   2  |  Marco |  February  |  2014  |   80.0
   3  |  Marco |  March     |  2014  |  135.5
   4  |  Marco |  April     |  2014  |   50.0
   5  |  Marco |  May       |  2014  |  200.0
   6  |        |  June      |  2014  |    0.0
   7  |        |  July      |  2014  |    0.0
   8  |        |  August    |  2014  |    0.0
   9  |        |  September |  2014  |    0.0
  10  |        |  October   |  2014  |    0.0
  11  |        |  November  |  2014  |    0.0
  12  |        |  December  |  2014  |    0.0

前5行是"常规"的一个例子。记录,其他人关于" hacking"在我的报告中,我需要12个月的交叉表。

问题:如果我从1月到11月运行此报告,此解决方案会将我带到一个包含空列的交叉表。如果填写了12月,则不会显示任何空白列。

原样:

            |         |  Marco  |  Mario  |  Luigi  |  Total
  January   |    0.0  |  150.0  |  150.0  |  150.0  |  450.0
  February  |    0.0  |   80.0  |   80.0  |   80.0  |  240.0
  March     |    0.0  |  135.5  |  135.5  |  135.5  |  406.5
  April     |    0.0  |   50.0  |   50.0  |   50.0  |  150.0
  May       |    0.0  |  200.0  |  200.0  |  200.0  |  600.0
  June      |    0.0  |    0.0  |    0.0  |    0.0  |    0.0
  July      |    0.0  |    0.0  |    0.0  |    0.0  |    0.0
  August    |    0.0  |    0.0  |    0.0  |    0.0  |    0.0
  September |    0.0  |    0.0  |    0.0  |    0.0  |    0.0
  October   |    0.0  |    0.0  |    0.0  |    0.0  |    0.0
  November  |    0.0  |    0.0  |    0.0  |    0.0  |    0.0
  December  |    0.0  |    0.0  |    0.0  |    0.0  |    0.0
  TOTAL     |    0.0  |  615.5  |  615.5  |  615.5  | 1846.5

期望:

            |  Marco  |  Mario  |  Luigi  |  Total
  January   |  150.0  |  150.0  |  150.0  |  450.0
  February  |   80.0  |   80.0  |   80.0  |  240.0
  March     |  135.5  |  135.5  |  135.5  |  406.5
  April     |   50.0  |   50.0  |   50.0  |  150.0
  May       |  200.0  |  200.0  |  200.0  |  600.0
  June      |    0.0  |    0.0  |    0.0  |    0.0
  July      |    0.0  |    0.0  |    0.0  |    0.0
  August    |    0.0  |    0.0  |    0.0  |    0.0
  September |    0.0  |    0.0  |    0.0  |    0.0
  October   |    0.0  |    0.0  |    0.0  |    0.0
  November  |    0.0  |    0.0  |    0.0  |    0.0
  December  |    0.0  |    0.0  |    0.0  |    0.0
  TOTAL     |  615.5  |  615.5  |  615.5  | 1846.5

问题:如何隐藏"空白"柱?有没有办法让它崩溃?

编辑:我试图将"空白"列完全空白,编辑将显示"空白"如果名称列组是"空白"太。然后,在列,度量和总单元格中,我检查了"如果空白则删除"选项没有结果。几个月和交叉表的其余部分之间仍有空间。 这就是我现在所拥有的:

            |         |  Marco  |  Mario  |  Luigi  |  Total
  January   |         |  150.0  |  150.0  |  150.0  |  450.0
  February  |         |   80.0  |   80.0  |   80.0  |  240.0
  March     |         |  135.5  |  135.5  |  135.5  |  406.5
  April     |         |   50.0  |   50.0  |   50.0  |  150.0
  May       |         |  200.0  |  200.0  |  200.0  |  600.0
  June      |         |    0.0  |    0.0  |    0.0  |    0.0
  July      |         |    0.0  |    0.0  |    0.0  |    0.0
  August    |         |    0.0  |    0.0  |    0.0  |    0.0
  September |         |    0.0  |    0.0  |    0.0  |    0.0
  October   |         |    0.0  |    0.0  |    0.0  |    0.0
  November  |         |    0.0  |    0.0  |    0.0  |    0.0
  December  |         |    0.0  |    0.0  |    0.0  |    0.0
  TOTAL     |         |  615.5  |  615.5  |  615.5  | 1846.5

1 个答案:

答案 0 :(得分:0)

无法使用iReport删除交叉表上的列。