Long-period spend analysis (>1 year)
Analyzes spending over periods exceeding 1 year by working around the 366-day API limit. Automatically aggregates results from multiple successive calls.
86/100ยท๐ Ad hocยทIntermediateCFOFinance Analyst
Spend analysisReportsspendesk_analyze_spend
๐ฏ Skill purpose
Analyzes spending over periods exceeding 1 year by working around the 366-day API limit. Automatically aggregates results from multiple successive calls.
๐ What it produces
Aggregated spending table by category, supplier, or team across the full requested period, with no gaps.
โก Benefit
Before
Impossible to get more than one year of data in one call โ manual quarterly analysis in Excel.
After
Complete multi-year analysis automatically reconstructed in a single Claude prompt.
# Instructions โ Spend analysis over a long period (> 1 year)
## โ ๏ธ Strict limit: 366 days maximum
`spendesk_analyze_spend` returns an explicit error if the period exceeds 366 days:
```
"fromDate must be on or before toDate, and the range cannot exceed 366 days."
```
**Solution**: split into sub-periods โค 366 days, call separately, combine the results.
## โ ๏ธ Second gotcha: limit=10 by default
For a groupBy=month over 12 months, the 2 least significant months are aggregated into an "Others" row.
โ Always pass `limit: 12` for a complete annual month-by-month analysis.
โ For 2 years: combine two calls with `limit: 12` each.
## Step 1 โ Calculate the sub-periods
Rule: each sub-period โค 365 days (leave a 1-day margin).
Examples:
- 2024 analysis: fromDate=2024-01-01, toDate=2024-12-31 โ
(365 days)
- 2025 analysis: fromDate=2025-01-01, toDate=2025-12-31 โ
(364 days)
- 2026 YTD analysis: fromDate=2026-01-01, toDate=2026-07-06 โ
(186 days)
## Step 2 โ Call each sub-period (in parallel if possible)
For each sub-period:
```json
{
"companyId": "...",
"fromDate": "YYYY-MM-DD",
"toDate": "YYYY-MM-DD",
"groupBy": ["month"],
"limit": 12
}
```
## Step 3 โ Combine the results
**Only combine after obtaining all results** (do not present a partial view).
Aggregation:
- `totalAmount`: sum the `summary.totalAmount.amount` of each sub-period (same functional currency)
- `totalCount`: sum the `summary.totalCount`
- Rows by month: concatenate the `data[]` arrays from both calls (no duplicates โ distinct periods)
โ ๏ธ If a sub-period contains an "Others" row: the month-by-month breakdown is **partial** for that period. Increase `limit` or narrow the period.
## Step 4 โ Year-over-year comparison
To compare 2024 vs 2025:
- Call 1: fromDate=2024-01-01, toDate=2024-12-31
- Call 2: fromDate=2025-01-01, toDate=2025-12-31
- Change = (totalAmount_2025 - totalAmount_2024) / totalAmount_2024 ร 100
Alternative: use `compareWithPreviousPeriod=true` on a period โค 366 days (automatically compares with the equivalent previous period).
## Live example (real data for this account)
| Period | Total (EUR) | # payables |
|---------|-------------|-------------|
| 2025 (Jan-Dec) | EUR 17,916,500.61 | 6,359 |
| 2026 (Jan-Jun) | EUR 8,174,523.65 | 3,937 |
Note: in the 2025 results, the default `limit=10` โ May and Sept. (the 2 least significant) fell into "Others". With `limit=12`, all months are visible.
## Example prompt
- "Analyze our spend over the last 2 years" โ 2 calls, year by year
- "Spend report 2024 vs 2025" โ 2 calls + comparison
- "Monthly trend since January 2024" โ split into 2 periods + limit=12
How to install this skill
/
- 1Download the file
s04-analyze-spend-periode-longue.mdusing the button above. - 2Place the file in the
.claude/directory of your project (or~/.claude/for a global install).cp s04-analyze-spend-periode-longue.md .claude/s04-analyze-spend-periode-longue.md - 3Use in Claude Code โ the skill is automatically discovered. Describe your need in natural language and Claude will apply the skill instructions.
๐ก Make sure the Spendesk MCP is configured in your
.claude/settings.json with the tools spendesk_analyze_spend.Similar skills
โ
Top