0

我是ssrs世界的新手。我只想在一个水平轴标签中使用两个间隔。例如,我在 X 轴上使用日期字段 (sample_date),对于 1 月,间隔为 31,2 月间隔为 28,12 月间隔为 31,等等。间隔类型为 Day。任何人都可以帮助我解决这个问题。

4

1 回答 1

0

当然,如果我相信我理解您的问题是您希望显示月末日期而不是日期。你需要做一些事情来做到这一点:

  1. 您需要从数据集中查看一个月中有多少天。这是一个示例数据集:

    declare @Dates table ( dt date, val int)
    
    insert into @Dates values('1-1-12', 10),('1-10-12',20),('1-30-12',14),('2-1-12', 11),('2-11-12', 19),('2-20-12', 20),('3-10-12',10)
    
    select *,  datediff(day,
    Dateadd(month, datediff(month, 0, dt), 0),
    Dateadd(day, -1, Dateadd(month, datediff(month, 0, dt) + 1, 0))
    ) as DaysInMonth
    from @Dates
    
  2. 您现在有了日期和值以及列表,告诉您该月有多少天。创建一个像你通常会的线或其他的图表。在示例中将“值”设置为“val”,在示例中将“类别组”设置为“dt”。

  3. 创建图表后,单击水平网格,直到该部分(x 轴)周围只有一个虚线矩形。单击“水平图表属性”。

  4. 将轴类型更改为“标量”单选按钮。选择如下:

    一种。将最小值更改为 [Min(dt)] b。将最大值更改为 [Max(dt)] c。将 Interval 更改为以下表达式:

    =(Fields!DaysInMonth.Value - 1)
    

    d。将间隔类型更改为“天”

  5. Run your report and it should be grouping by days, but using the data you found to be the count of days in a month dynamically at run time. Since you are subtracting one from this number it should show the grouping for the first day but then the last day each time. If you find this not to be true I would alter the expression slightly as when I tested it, it worked for the duration I gave.

If this fails you could set a label to be the last day of the month obtained from a sql statement and have that be your 'label' for a category group possibly as well.

于 2013-01-21T19:22:17.767 回答