data analysis.md

Data Analysis

Top expense categories for a quarter (read)

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

The Script

#!/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

What It Outputs

Cloud Infrastructure: $12500.00 (36 transactions)
Payroll: $75000.00 (3 transactions)
Cash flow statement by month (read)

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

The Script

#!/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

What It Outputs