> For the complete documentation index, see [llms.txt](https://docs.kick.co/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.kick.co/ai/cli/cli-use-case-library/data-analysis.md).

# Data Analysis

Summarize expenses by category and export cash flow statement data with Kick CLI read commands and jq.

<details>

<summary><strong>Top expense categories for a quarter</strong> (read)</summary>

To see where spend concentrated last quarter, pull transactions and group negative amounts by category.

**The Script**

```bash
#!/bin/bash
# top-expense-categories.sh

WORKSPACE_ID="<workspace-id>"
SINCE="2026-01-01"
UNTIL="2026-03-31"

echo "Top expense categories: $SINCE to $UNTIL"
echo ""

kick --workspace "$WORKSPACE_ID" transactions find \
  --since "$SINCE" \
  --until "$UNTIL" \
  --fields amount,category \
  --output json | \
jq -r '
  [.[] | select(.amount < 0)] |
  group_by(.category) |
  map({
    category: (.[0].category // "Uncategorized"),
    total: (map(.amount) | add),
    count: length
  }) |
  sort_by(.total) |
  .[] |
  "\(.category): $\(.total | fabs) (\(.count) transactions)"
'
```

**How to Customize**

* Filter to one entity's activity in Kick before exporting, or narrow dates per client
* Group by counterparty instead: `group_by(.counterparty)`
* Add a percentage of total with an extra `jq` pass

**What It Outputs**

```
Cloud Infrastructure: $12500.00 (36 transactions)
Payroll: $75000.00 (3 transactions)
```

</details>

<details>

<summary><strong>Cash flow statement by month</strong> (read)</summary>

To analyze operating, investing, and financing totals by month, use the cash flow statement report instead of rolling up raw transactions.

**The Script**

```bash
#!/bin/bash
# cash-flow-by-month.sh

WORKSPACE_ID="<workspace-id>"
ENTITY_ID=123
START_DATE="2026-01-01"
END_DATE="2026-03-31"

ledger_id=$(kick --workspace "$WORKSPACE_ID" accounting ledgers get --entity-id "$ENTITY_ID" --output json | jq -r '.ledgers[0].id')

kick --workspace "$WORKSPACE_ID" reports cash-flow-statement \
  --entity "$ENTITY_ID" \
  --ledger-id "$ledger_id" \
  --start-date "$START_DATE" \
  --end-date "$END_DATE" \
  --cycle month \
  --output json | jq .
```

**How to Customize**

* Add `--comparison previous_year` for year-over-year context
* Export vendor-level detail with `kick reports expenses-by-vendor` for the same entity and dates

**What It Outputs**

* JSON cash flow statement with monthly columns for the entity and period

</details>


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.kick.co/ai/cli/cli-use-case-library/data-analysis.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
