【问题标题】:Bar Chart with two values in "Change On", skip bars with value 0“更改开”中有两个值的条形图,跳过值为 0 的条形图
【发布时间】:2018-10-12 22:33:55
【问题描述】:

我有一个基于以下 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'

也就是说,我有三天的数据,每天,一些名字可能会出现多次。我现在想显示一个图表,在该图表中,我可以查看每个名称出现的频率。我尝试使用以下设置:

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

但是,问题是图表每天为所有两个名字保留空间。当有两个以上的名字并且每天只出现几个名字时,这就会成为一个问题。

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

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'

对于每一天,都会为在任何一天出现的每个名称保留空间。是否可以让 Crystal Reports 跳过这些列,只为值不是 0 的列保留空间?

【问题讨论】:

    标签: crystal-reports


    【解决方案1】:

    据我所知,Crystal Reports 的内置柱形图无法做到这一点。至少,不是“自然地”。

    但是,根据您的要求,您可以尝试如下所述的方法。但是你将不得不使用数据和选项来尝试获得一些像样的东西。

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

    首先,将您的选择命令更改为如下内容:

    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
    

    然后你像这样配置你的柱形图:

    第一个结果会很丑。那么挑战是如何使它看起来像。也许不可能让它足够好。但是不会有“零列”。

    开始时的提示是使用列标签而不是图例并注意顺序。

    【讨论】:

    • 感谢您的回答,但它错过了一些重要要求(对于问题起源的用例):按天对列进行分组,并为同一个人使用相同的颜色。
    • Yoy 可能会尝试另一种可能不太好的可能性:按日期对详细信息进行分组,并将每个日期绘制在单独的图表中。但我认为结果会更糟,颜色可能不匹配。我没有尝试过这个,我只是在大声思考。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-03
    • 2012-01-19
    • 2014-08-02
    • 2021-05-31
    相关资源
    最近更新 更多