条形图在“更改为”中具有两个值,跳过值为0的条形图

时间:2018-05-02 18:12:07

标签: crystal-reports

我有一个基于以下sql语句的Crystal Reports条形图:

Select 'Max' as Name, '2018-05-02' as Day
union all select 'Max', '2018-05-02'
union all select 'Max', '2018-05-02'
union all select 'Fritz', '2018-05-02'
union all select 'Fritz', '2018-05-02'
union all select 'Fritz', '2018-05-03'
union all select 'Fritz', '2018-05-03'
union all select 'Fritz', '2018-05-03'
union all select 'Max', '2018-05-04'

即我有三天和每天的数据,有些名字可能会出现多次。我现在想要显示一个图表,每天都会看到每个名字出现的频率。我尝试使用以下设置:

enter image description here

我得到的结果非常接近我想要达到的目标:

enter image description here

然而,问题是图表为每天的所有两个名称预留了空间。当有两个以上的名称并且每天只出现几个名称时,这就成了一个问题。

就像在这个例子中有更多的名字,每个名字只出现在几天:

Select 'Max' as Name, '2018-05-02' as Day
union all select 'Max', '2018-05-02'
union all select 'Max', '2018-05-02'
union all select 'Hans', '2018-05-02'
union all select 'Beate', '2018-05-02'
union all select 'Luise', '2018-05-02'
union all select 'Sandra', '2018-05-02'
union all select 'Fritz', '2018-05-02'
union all select 'Fritz', '2018-05-02'
union all select 'Fritz', '2018-05-03'
union all select 'Fritz', '2018-05-03'
union all select 'Fritz', '2018-05-03'
union all select 'Max', '2018-05-04'
union all select 'Rainer', '2018-05-04'
union all select 'Elvira', '2018-05-04'
union all select 'Silvia', '2018-05-04'

enter image description here

对于每一天,为任何日子出现的每个名字保留空格。是否可以使Crystal Reports跳过这些列,并仅为值不是0的列保留空间?

1 个答案:

答案 0 :(得分:0)

据我所知,不可能在Crystal Reports的内置柱形图中完成该操作。至少不是“自然地”。

但是,根据您的要求,您可以尝试以下所述的方法。但是您将不得不使用数据和选项来尝试使事物具有表现力。

基本思想是格式化数据,以便该图表将成为常见的柱形图(无组)。这样,您就摆脱了“零列”。

首先,将您的select命令更改为以下内容:

select Name, Day, Day + ': ' + Name as DayAndName, Count(*) as Count from (
    Select 'Max' as Name, '2018-05-02' as Day
    union all select 'Max', '2018-05-02'
    union all select 'Max', '2018-05-02'
    union all select 'Hans', '2018-05-02'
    union all select 'Beate', '2018-05-02'
    union all select 'Luise', '2018-05-02'
    union all select 'Sandra', '2018-05-02'
    union all select 'Fritz', '2018-05-02'
    union all select 'Fritz', '2018-05-02'
    union all select 'Fritz', '2018-05-03'
    union all select 'Fritz', '2018-05-03'
    union all select 'Fritz', '2018-05-03'
    union all select 'Max', '2018-05-04'
    union all select 'Rainer', '2018-05-04'
    union all select 'Elvira', '2018-05-04'
    union all select 'Silvia', '2018-05-04'
) X
group by Name, Day

然后按以下方式配置柱形图: enter image description here

第一个结果将是丑陋的。接下来的挑战是如何使其具有表象性。也许不可能使其足够好。但是不会有“零列”。

开始的提示是使用列标签代替图例,并注意顺序。

相关问题