> For the complete documentation index, see [llms.txt](https://www.boxhero.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.boxhero.io/docs/documentation/ja/sonono/custom-analytics.md).

# カスタム分析

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

***

## 主なポイント

* 平易な言葉で質問すると、 **AIアシスタント** がSQLを作成します。
* SQLを使ってBoxHeroのデータを検索できます。
* アイテム、属性、価格、日付範囲、取引先などの条件を組み合わせて、返したいデータをカスタムレポートとして定義できます。
* よく使うクエリを保存して、いつでも再度開けます。
* 結果をExcelにエクスポートして、さらに分析やレポート作成に活用できます。

## ユースケース

標準機能 <mark style="color:$primary;">`在庫レポート`</mark> この機能では、選択した期間の平均在庫数量や在庫回転率などの主要指標をすぐに確認できます。これらのレポートはあらかじめ定義された数式とフィールドを使用するため、チームに必要なあらゆる分析を網羅できるとは限りません。

<mark style="color:$primary;">`カスタム分析`</mark> データの見方をより細かく制御できます。特に次のような場合に便利です。

* 必要なデータが標準機能で見つからない [在庫レポート](/docs/documentation/ja/sonono/analytics.md)
* アイテム、仕入先、顧客、担当メンバー、その他の詳細条件でデータを絞り込んだりグループ化したい
* 月次、四半期ごと、前年比などの時系列分析が必要
* 頼りにしているレポートを保存して、再利用したい
* レポート作成や意思決定を支える柔軟なデータが必要

***

## カスタム分析の使い方

### 1. はじめる

次へ <mark style="color:$primary;">`レポート`</mark> > <mark style="color:$primary;">`カスタム分析`</mark>. これにより、SQLクエリを作成・管理できる新しいワークスペースが開きます。次に、 <mark style="color:$primary;">`+ 新規`</mark> をクリックして新しいクエリを作成します。

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

### 2. クエリを作成する

クエリを作成する方法は2つあります。

1. **AIアシスタントを使って** 平易な言葉の質問からSQLを生成します（ほとんどのユーザーにおすすめです）。
2. **SQLを直接記述する** を使って [DuckDB SQL](https://duckdb.org/docs/stable/sql/introduction).

<figure><img src="/files/8434f93138e4ef4ff9d2e7df8bf2065ff584b1da" alt=""><figcaption></figcaption></figure>

#### AIアシスタントを使うと

その <mark style="color:$primary;">`AIアシスタント`</mark> 平易な言葉の質問を実行可能なSQLクエリに変換します。SQLを知らなくても使えます。&#x20;

アシスタントパネルに質問を入力してEnterを押します。アシスタントがSQLを生成し、エディタに反映して実行します。結果はクエリの下に表示されます。

必要に応じて、保存前に生成されたSQLを編集して調整できます。

{% embed url="<https://customer-0jrbilsa8yt3k758.cloudflarestream.com/38e5c1fa675d1d7f16b1d9e95a6aabd4/iframe?autoplay=true&controls=false&letterboxColor=transparent&loop=true&muted=true&poster=https://customer-0jrbilsa8yt3k758.cloudflarestream.com/38e5c1fa675d1d7f16b1d9e95a6aabd4/thumbnails/thumbnail.jpg?height=1080&preload=true>" %}

**質問例**

* 安全在庫レベルを下回っているアイテム
* 過去90日間に売れていないものは何ですか？
* 今月の販売数量上位10件のSKU
* 到着予定日を過ぎても未着の発注書
* 拠点別の在庫レベル&#x20;

#### 再利用可能なクエリの作成

日付範囲や取引先名など、調整可能なフィルターをクエリに含めるようアシスタントに依頼できます。アシスタントはクエリ変数を使用するため、SQLを書き直さなくても後から入力値を変更できます。

たとえば、 *「変更可能な期間のアイテム別売上」* と依頼すると、クエリ実行のたびに入力を求める日付変数付きのクエリが生成されます。

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

{% hint style="warning" %}
AIアシスタントは **具体的な** **質問**. \
の代わりに *「売上を表示して」* 試しに *「今月の収益上位10アイテム」*
{% endhint %}

{% embed url="<https://customer-0jrbilsa8yt3k758.cloudflarestream.com/27509a71c500d77cd43f29409abe0d68/iframe?autoplay=true&controls=false&letterboxColor=transparent&loop=true&muted=true&poster=https://customer-0jrbilsa8yt3k758.cloudflarestream.com/27509a71c500d77cd43f29409abe0d68/thumbnails/thumbnail.jpg?height=1080&preload=true>" %}

{% hint style="success" %}
「 <mark style="color:$primary;">`チャート`</mark> 」ボタンをクリックするとデータを可視化できます — 棒グラフ、折れ線グラフ、円グラフ、積み上げ棒グラフ、積み上げ面グラフに対応しています。
{% endhint %}

### 3. クエリを保存する

選択 <mark style="color:$primary;">`実行`</mark> を試して、クエリを検証します。結果は記述した条件に依存するため、出力を確認して期待どおりか検証してください。

クエリを再利用する予定がある場合は、 <mark style="color:$primary;">`保存`</mark> 右上隅で。保存したクエリは左サイドバーに表示され、いつでも開いて実行できます。

クエリの実行に成功したら、結果を <mark style="color:$primary;">`Excelにエクスポート`</mark>.

<figure><img src="/files/1572e1ba07c0218a0cb720d40595a48d88daa2d1" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
データは自動的に同期されます **1日1回**.\
サイドバー下部の同期アイコン（🔄）をクリックすると、すぐに同期できます。
{% endhint %}

***

## クエリ変数

を含めると、 `{{variable_name}}` がクエリ実行時に自動生成されます。そのフィールドに入力した値が、SQLクエリ内の変数に適用されます。

クエリを保存すると、チームメンバーは変数欄に独自の値を入力し、必要なときにいつでもレポートを実行できます。

#### 例

1. 特定のキーワードを含むアイテムを検索するには、次のクエリを入力してください：

```sql
select sku, name 
from items 
where name ilike '%' || {{item_name}} || '%';
```

2. クエリを実行すると、 **item\_name** という名前の入力フィールドが表示されます。

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

3. たとえば *`sweater`* などのキーワードを入力すると、結果には名前に *「sweater」* を含むすべてのアイテムが表示されます。

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

4. 再度使う予定がある場合は、クエリを保存してください。保存したクエリは左側メニューからいつでも選択して読み込めます。

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

***

## 例

カスタム分析には、すぐに実行できる組み込みテンプレートが含まれています。テンプレートを確認して仕組みを理解し、必要に応じて調整するか、新しいクエリを作成してください。

#### テンプレート

* 週間在庫入出庫レポート
* 月次の仕入れ・売上トレンド
* アイテム別の最終出庫日

<figure><img src="/files/0ad37a16ac011ebfa71a13a74561ab3d8989ee93" alt=""><figcaption></figcaption></figure>

***

## よくある質問

**まだ質問がありますか？** カスタム分析FAQをご覧ください：

{% content-ref url="/spaces/Zvjcst6XueuNcyPRjnhb/pages/05a52af5a85de69a431f3cb5366fd57c105703b6" %}
[カスタム分析](/docs/faq/ja/repto/kasutamu.md)
{% endcontent-ref %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://www.boxhero.io/docs/documentation/ja/sonono/custom-analytics.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
