Provincial cities and counties grouped on the issue in the same field

General Packet Reports

For grouped reports, frequently encountered is the provincial cities and counties table structure in different fields.
Such a structure, doing group on the report when it is very simple, direct group function can be performed on different field belongs.
As shown below:

imagepng

imagepng

imagepng

Special structure

However, there will always be some tables special structure
of this example shown at FIG.

imagepng

Provincial cities and counties are rural with memory in a field.
Each village has its own independent id. id pid associated with its parent directory. within pids is associated with a top-down hierarchy.
This table structure, when doing group on the report, the primary consideration is how to separate the issue at all levels area.

The main point is to distinguish between the association and the id of pid.
Grouping function, is bound to be used ds.group ()
because it is the same field, the need is ds.group@r ()

Function Description

The packet expression dataset from the selected set of components set.

根据分组表达式,从数据集中选出一组组集。

    datasetName.group (<selectExp: order1> {, {groupSortExp filterExp ;;}}: {groupOrderExp}) 
    // need not apply to the data set has been sorted or sorted. This function is to optimize the wording below, and packet fields are generally the same sort field.   
    datasetName.group (<selectExp> {, filter_exp }; {sort1} {: order1}, ...; {groupSortExp}: {groupOrderExp}) 
Parameters: 
        selectExp selected packets expression, the field may be a column name / column number, It can also be an expression. 
                      Column number #n is represented by, for example, # 0 represents the 0, # 1 represents the first one, and so on 
        filterExp filter expression 
        sort1 packet recorded before expression sort 
        packet sequence before sorted records order1, abbreviated as not sorted ,> 0 ascending <0 descending; order1, .., ordern ascending omitted when 
        the expression of packet ordering group groupSortExp, general summary calculation expression, combination meter, 
        groupOrderExp group sort order> 0 ASC < 0 descending 
return value: 
     a collection of data, the data type is determined by the calculation result of selectExp 
options: 
        @r contents of the data set is the root of the expression

datasetName.group(<selectExp:order1>{,filterExp};;{ groupSortExp }:{ groupOrderExp }) //适用于不需要排序或数据集中已排好序。此函数是下面的优化写法,分组字段和排序字段通常是同一个。 datasetName.group(<selectExp>{,filter_exp};{sort1}{:order1},…;{ groupSortExp }:{ groupOrderExp }) 参数说明: selectExp 选出的分组表达式,可以是字段列名/列号,也可以是表达式。 列号用#n表示,例如#0代表第0列,#1代表第1列,依此类推 filterExp 过滤表达式 sort1 分组前记录的排序依据表达式 order1 分组前记录的排序顺序,省略为不排序,>0升序,<0降序;order1,..,ordern省略时升序 groupSortExp 分组后对组的排序表达式,一般是汇总运算的表达式,如组合计等 groupOrderExp 组排序顺序,>0升序,<0降序 返回值: 一组数据的集合,数据类型由selectExp的运算结果来决定 选项: @r 是否为根数据集表达式

Implementation

As shown below:

imagepng

Provinces is very simple, direct = ds2.group (id, pid == 0) to display the value of the expression is: ds2.select (name, id == value ())

City wording of =ds2.group@r (id, pid == A4; id: 1) according to pid do association.
County, town and village wording similar association for the parent cell to cell.
Displays the value of the same wording as ds2.select (name, id == value ( ))

All correlation value takes the value taken id display name.

The end result is:

imagepng

Published 48 original articles · won praise 13 · views 20000 +

Guess you like

Origin blog.csdn.net/zozoxxma/article/details/103660095