본문으로 건너뛰기
AUISoft에이유아이소프트
AUIPivot v2.8 DEMO

고객별 매출 집중도와 거래 폭

Report

고객별 매출 비중과 구매 실적을 매출액이 큰 순서로 출력한 보고서입니다.

고객 번호를 행 필드에 놓고 매출액, 매출 비중, 판매 기록 수, 판매 대수와 구매 모델 수를 값 필드에 지정하십시오.

CUSTOMER_ID는 데모용 가상 고객 번호입니다. 기간 또는 지점을 변경하면 기존 필터를 해제하고 선택한 조건을 적용합니다.

// 고객 번호 순서로 행을 묶습니다.
AUIPivot.setRowFields(myPivotID, ["CUSTOMER_ID"]);

// 값 필드와 집계 연산자 지정하기
AUIPivot.setValueFields(myPivotID, [
    // 매출액
    { dataField: "TOTAL", operation: "SUM", customLabelText: "매출액", formatString: "#,##0" },
    // 매출 비중
    { dataField: "TOTAL", operation: "GRAND_TOTAL_RATIO", customLabelText: "매출 비중", formatString: "0.00%" },
    // 판매기록 수: 값이 있는 기록을 한 건씩 셉니다.
    { dataField: "PRICE", operation: "COUNT", customLabelText: "판매기록 수", formatString: "#,##0" },
    // 판매 대수
    { dataField: "COUNT", operation: "SUM", customLabelText: "판매 대수", formatString: "#,##0" },
    // 구매 모델 수
    { dataField: "MODEL", operation: "DISTINCT_COUNT", customLabelText: "구매 모델 수", formatString: "#,##0" }
]);

// 계산 완료 후 고객 매출을 큰 순서로 정렬합니다. 행, 열 구성이 다른 경우에는 정렬을 건너뜁니다.
function sortCustomerSales(myPivotID) {
    if (JSON.stringify(AUIPivot.getRowFields(myPivotID)) !== '["CUSTOMER_ID"]')
        return;
    if (!AUIPivot.getColumnFields(myPivotID).every(field => field === "_$valueFields"))
        return;
    const sales = AUIPivot.getColumnInfoList(myPivotID).find(column => column.opDataField === "TOTAL::SUM");
    if (sales)
        AUIPivot.setSorting(myPivotID, [{
                // 설정을 적용할 필드 이름입니다.
                dataField: sales.dataField,
                // 1은 오름차순, -1은 내림차순입니다.
                sortType: -1
            }, {
                dataField: "_$rowLabel",
                sortType: 1
            }], true);
}
// 처음 자료를 넣기 전에 한 번만 등록합니다.
AUIPivot.bind(myPivotID, "pivotComplete", function () { sortCustomerSales(myPivotID); });

함께 보기: DISTINCT_COUNT, 중복 없는 고객 수