> 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

<details>

<summary><strong>Top Expense Categories This Quarter</strong></summary>

**The Script**

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

QUARTER_START="2026-01-01"
QUARTER_END="2026-03-31"

echo "Top Expense Categories: $QUARTER_START to $QUARTER_END"
echo ""

kick transactions list \
  --from="$QUARTER_START" \
  --to="$QUARTER_END" \
  --filter="amount<0" \
  --format=json | \
jq -r '
  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**

* Change to revenue categories
* Group by counterparty instead
* Add percentage of total

**What It Outputs**

```
Cloud Infrastructure: $12,500.00 (36 transactions)
Payroll: $75,000.00 (3 transactions)
```

</details>

<details>

<summary><strong>Cash Flow Trend Analysis</strong></summary>

**The Script**

```bash
#!/bin/bash
# cash-flow-trends.sh

START_DATE="2026-01-01"
END_DATE="2026-03-31"

echo "Week Starting,Inflows,Outflows,Net"

kick transactions list \
  --from="$START_DATE" \
  --to="$END_DATE" \
  --format=json | \
jq -r '
  group_by(.date[0:10] | strptime("%Y-%m-%d") | strftime("%Y-W%U")) |
  map({
    week: (.[0].date[0:10] | strptime("%Y-%m-%d") | strftime("%Y-%m-%d")),
    inflows: (map(select(.amount > 0) | .amount) | add // 0),
    outflows: (map(select(.amount < 0) | .amount | fabs) | add // 0)
  }) |
  map("\(.week),\(.inflows),\(.outflows),\(.inflows - .outflows)") |
  .[]
'
```

**How to Customize**

* Change to monthly instead of weekly
* Add rolling averages
* Export to CSV for charting

**What It Outputs**

```
Week Starting,Inflows,Outflows,Net
2026-01-06,25000.00,18500.00,6500.00
```

</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 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://docs.kick.co/ai/cli/cli-use-case-library/data-analysis.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.
