# 19. 합계를 표현하고 싶어요.

이 가이드에서는 특정 숫자 값의 합계를 표현하는 방법을 소개해 드릴게요.&#x20;

{% hint style="info" %}
'\[완성형]쇼핑몰' 패키지를 기준으로, '쇼핑몰 관리자 용 앱에서 총매출액을 확인할 수 있도록 설정한다.'는 가정으로 예시를 들어볼게요.
{% endhint %}

완성 화면은 다음과 같아요.&#x20;

<div align="left"><figure><img src="/files/3yQEycxPvFBuv9DxRBxU" alt="" width="384"><figcaption></figcaption></figure></div>

1. **배경 설명**
   * \[완성형]쇼핑몰 패키지에는 결제 데이터를 '주문 관리' 메타에서 파악할 수 있어요.
   * '주문 관리' 메타에서 '주문 상태' 항목으로 해당 주문건의 상태를 판단하고 있어요.  \[주문 상태 : 구매 확정(purchaseConfirmed)]일 때를 매출로 판단했어요.
   * countByMeta레고를 사용해 총 합을 계산해요. <br>
2. **먼저 매출액을 표현할 메뉴(메타)를 생성해요.**

   * 관리자 웹 > 메뉴 설정 > 앱 메뉴 설정 > 화면 추가

   아래의 이미지와 같이  '메뉴명',&#x20;
3. '메타ID'를 설정해 주세요. 메뉴명과 메타ID는 원하는 대로 작성해 주세요.&#x20;

<div align="left"><figure><img src="/files/ZsqiEW9DBw3T4pyRPdiV" alt="" width="563"><figcaption></figcaption></figure></div>

**관리자 웹 > 앱 설정 > 총 매출액 메뉴 > 커스텀 화면**

1. '변수 텍스트'로 제목 표현하기

아래의 이미지와 같이 '변수 텍스트'를 이용해서 제목을 표현할 수 있어요. 스타일과 내용은 편하게 작성해 주세요.

<figure><img src="/files/wveKidTYMqEubmXP2Q1C" alt=""><figcaption></figcaption></figure>

2. listByMeta로 '구매 확정'된 주문 건들 받아오기

listByMeta 블록 추가 후,  다음과 같이 설정해 주세요.

1. 메타 코드 : 주문건이 존재하는 메타
2. 앱 화면 선택 : listMeta
3. 필터 설정
   * 조건 항목: status(주문 상태를 확인할 수 있는 항목)
   * 조건: 같다
   * 조건 값: purchaseConfirmed(구매 확정)

<figure><img src="/files/orHJwh2rJA1VZB205fzs" alt=""><figcaption></figcaption></figure>

3. countByMeta로 총 합 계산하기

countByMeta 블록 추가 후 다음과 같이 설정해 주세요.  countByMeta 블록의 항목 ID는 이후에도 사용하니, 기억해 주세요.

* 체인 > Send
  * 체인 액션 타입 : 변경
  * 체인 Send 키 : priceChange (자유롭게 작성해 주세요.)
* 데이터 설정
  * 컬렉션 명 : pkg\_shopCompleted\_order (주문건이 있는 메타)
  * 가져온 데이터에서 사용할 항목ID : totalAmount (자유롭게 작성해 주세요.)
* 그룹
  * 다음의 코드를 복사해 주세요.&#x20;
  * `{` \
    &#x20;   `"_id": {`\
    &#x20;       `"id": "status"`\
    &#x20;   `},`\
    &#x20;   `"totalAmount": {`\
    &#x20;       `"sum": "productPrice"` \
    &#x20;   `}` \
    `}`<br>
  * &#x20;'status'는 주문 상태를 나타내는 항목이고 'productPrice'는 상품의 가격을 나타내는 항목이에요.
* 필터 설정
  * 조건 항목: status
  * 조건: 조건 값과 같다
  * 조건 값: purchaseComfirmed

<figure><img src="/files/qd3rJNgIMCRJ7N1jHpIq" alt=""><figcaption></figcaption></figure>

4. '변수 텍스트'로 총 합 표현하기

   1. 변수 텍스트 블록 추가 후,  텍스트에 다음과 같이 입력해 주세요. 이때, ${} 내부의 count는 countByMeta 블록의 항목ID예요.&#x20;
      * 총합 : ${inputData.count}
   2. 체인 > Receive 선택 후,  앞에서 설정한 Send키 값을 그대로 입력해 주세요.

   <figure><img src="/files/dBKubGeaG6tluhqByo9X" alt=""><figcaption></figcaption></figure>
5. 저장 후, 새로고침해 주세요.

24.02.16 Jinny


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.ohmyapp.io/main/guide/faq/app-settings/19.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
