每月显示12列,但月份值取决于用户选择的月份 [英] Display 12 columns each for a month but month values dependent on User selected Month

查看:56
本文介绍了每月显示12列,但月份值取决于用户选择的月份的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Crystal Reports for VS2010。



我对独立CR有以下要求:



从指定的开始日期开始,检索表中未来12个月的所有销售记录。 StartDate是报告使用和用户选择的参数。



列如下:Month1是StartDate的月份,后面是连续几个月。



Column1 Column2 Month1 Month2 M3 M4 M5 M6 M7 M8 M9 M10 M11 M12

例如:如果StartDate是01/05/2013(2013年5月),那么列应该是be:



Column1 Column2 May13 Jun13 Jul13 Aug13 Sep13 Oct13 Nov13 Dec13 Jan14 Feb14 Mar14 Apr14



真的感谢有人可以指点链接或指示如何实现这个目标。





更新:



我已设法使用公式实现动态列标题



ToText(DateAdd('m',1,{?StartDate }),'MMM yy')

我很难找到一个公式来获取详细信息部分中的数据值。如果字段名称是{Sales.Extension},我该如何计算该月的扩展总和。

解决方案

主要思想是按原样使用Cross-Tab描述此处 [ ^ ]。



看看这里:包含动态列的结晶报告 [ ^ ]


我使用的是std公式方式,而不是使用交叉表(这么复杂,我讨厌它)。 br />


每月创建12个公式标题

 @ m1:ToText({?StartDate},'MMM yy')
@ m2:ToText(DateAdd('m',1,{?StartDate}),'MMM yy')



依此类推至12.



这会给出一个动态标题,列出月份名称列标题。



对于数据部分,



@ ext1:

  if  ToText({SALES_TX_HDR.sale_date},'  MMM yy')= {@ m1}然后
{SALES_TX_LINES.extension}





@ ext2:< pre lang =cs> if ToText({SALES_TX_HDR.sale_date},' MMM yy')= {@ m2}然后
{SALES_TX_LINES.extension}





答案依此类推。



按我要的方式列出当月商品的销售总额。



谢谢各位赞赏。


Using Crystal Reports for VS2010.

I have the following requirement for a standalone CR.:

From the indicated start date, retrieve all sales records from the table for the next 12 months. StartDate is the parameter that report uses and user selects.

Columns are as under: Month1 is the month of the StartDate followed by consecutive months.

Column1 Column2 Month1 Month2 M3 M4 M5 M6 M7 M8 M9 M10 M11 M12
For eg: If StartDate is 01/05/2013 (May 2013) then columns should be:

Column1 Column2 May13 Jun13 Jul13 Aug13 Sep13 Oct13 Nov13 Dec13 Jan14 Feb14 Mar14 Apr14

Would really appreciate if someone could point me to links or give some directions on how to achieve this.


UPDATE:

I have managed to achieve the Dynamic column headers using formula

ToText(DateAdd('m', 1, {?StartDate}), 'MMM yy')
I am stuck figuring out a formula to get the data value in the Detail section. If field name is {Sales.Extension} how do I calculate the Sum of Extension for that Month only.

解决方案

The main idea is to use Cross-Tab as is described here[^].

Have a look here: Crystal report with Dynamic Column[^]


Instead of using Crosstab (so much complicated and I hate it), I used the std formula way.

Created 12 formulae one each month header

@m1: ToText({?StartDate}, 'MMM yy') 
@m2: ToText(DateAdd('m', 1, {?StartDate}), 'MMM yy')


And so on upto 12.

This gives a dynamic header listing the Month names in the Column Headers.

For the data part,

@ext1:

if ToText({SALES_TX_HDR.sale_date}, 'MMM yy') = {@m1} Then
        {SALES_TX_LINES.extension}



@ext2:

if ToText({SALES_TX_HDR.sale_date}, 'MMM yy') = {@m2} Then
        {SALES_TX_LINES.extension}



Ans so on.

Works as I want listing the Sum of sales for an item for that month.

Thanks Guys appreciate it.


这篇关于每月显示12列,但月份值取决于用户选择的月份的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆