我如何计算 crystal 报告中的唯一日期?
How do i count unique dates in crystal report?
我有一份 crystal 销售报告并按销售日期分组。这会在报告中添加一个按 header 分组的分组。是否可以统计报告中有多少 header?
原因是我需要计算销售日期的唯一数量!
谢谢
有两种方法。您可以根据需要使用这些方法中的任何一种。
1.) Create a sql query and group by the field that you want. how you can get the no of count record in your sql query Count(1) As TotalItems
. You can use that field in your crystal report directly. If you are creating command with group caluse then you don't need to take do any further process to calulate the number of group items.
2.) You can create two formula fields 'Initializer and 'Incremental
. In the Initializer
formula field you can take a numbervar
variable and assign it with 0
then you can increment it with +1
in Incremental
formula field. This formula field should be placed in your group header. How you can get total number of header printed in report. This process is much easier than 1st. But, in this method you will get total group header only at the end of the report. If you are using this method then don't forget to use WhilePrintingRecords
keyword at the top of the formula in formula field.
对于Initializer
WhilePrintingRecords;
numbervar dTotalCount :=0;
对于Incremental
WhilePrintingRecords;
numbervar dTotalCount; //do not assign 0 otherwise it will not get correct result
dTotalCount:= dTotalCount + 1;
您可以创建另一个公式字段以仅显示 dTotalCount
值。
WhilePrintingRecords;
numbervar dTotalCount;
dTotalCount; //Don't need to do anything. Just declaration requred.
我有一份 crystal 销售报告并按销售日期分组。这会在报告中添加一个按 header 分组的分组。是否可以统计报告中有多少 header?
原因是我需要计算销售日期的唯一数量!
谢谢
有两种方法。您可以根据需要使用这些方法中的任何一种。
1.) Create a sql query and group by the field that you want. how you can get the no of count record in your sql query
Count(1) As TotalItems
. You can use that field in your crystal report directly. If you are creating command with group caluse then you don't need to take do any further process to calulate the number of group items.2.) You can create two formula fields 'Initializer
and 'Incremental
. In theInitializer
formula field you can take anumbervar
variable and assign it with0
then you can increment it with+1
inIncremental
formula field. This formula field should be placed in your group header. How you can get total number of header printed in report. This process is much easier than 1st. But, in this method you will get total group header only at the end of the report. If you are using this method then don't forget to useWhilePrintingRecords
keyword at the top of the formula in formula field.
对于Initializer
WhilePrintingRecords;
numbervar dTotalCount :=0;
对于Incremental
WhilePrintingRecords;
numbervar dTotalCount; //do not assign 0 otherwise it will not get correct result
dTotalCount:= dTotalCount + 1;
您可以创建另一个公式字段以仅显示 dTotalCount
值。
WhilePrintingRecords;
numbervar dTotalCount;
dTotalCount; //Don't need to do anything. Just declaration requred.