How do I calculate totals by week?
Recipe verified on
Ran on the public demo (read-only)
Short answer
Group by a week column and sum. In the demo every order carries order_week (ISO weeks such as 2025-W10), so your AI asks for revenue and order counts per week in one query and gets a row per week.
Steps
- Connect your assistant to the public demo. It's a read-only instance with 10 million synthetic orders,
so you can try this before you have your own. In Claude Code:
claude mcp add --transport http mcpdata-demo https://demo.mcpdata.org/mcp --header "Authorization: Bearer cdb_live_PkVoldus8qcE-hqffjajNZzQwiA7rTHMoR4RLSAxsCE"
The key is public on purpose: it can only read the demo's sample data. For Claude Desktop, Cursor and other apps, see Connect your AI.
- Ask your question. Give your AI this prompt:
Using mcpdata, total revenue and number of orders per week for 2025 from Demo.Orders.
What your AI does: the tool call it makes for this prompt, and what came back
query(table_name="Demo.Orders", filters=[{"column": "order_year", "op": "eq", "value": 2025}], group_by=["order_week"], agg=[{"func": "sum", "column": "revenue", "alias": "revenue"}, {"func": "count", "column": "order_id", "alias": "orders"}], sort=[{"column": "order_week", "desc": false}], limit=60) → 53 rows
| order_week | revenue | orders |
|---|---|---|
| 2025-W01 | 26,153,067 | 48,132 |
| 2025-W02 | 35,330,664 | 65,813 |
| 2025-W03 | 35,399,981 | 66,328 |
| 2025-W04 | 35,801,970 | 66,755 |
| 2025-W05 | 35,647,639 | 66,018 |
| 2025-W06 | 36,004,383 | 66,949 |
| 2025-W07 | 35,688,420 | 67,109 |
| 2025-W08 | 35,964,719 | 67,043 |
| 2025-W09 | 36,096,521 | 67,353 |
| 2025-W10 | 36,153,109 | 67,295 |
| 2025-W11 | 36,590,016 | 67,930 |
| 2025-W12 | 36,086,525 | 67,427 |
Synthetic data: the demo's orders are generated, not real customers.
The assistant needs mcpdata connected (step 1) to run the query.
Why this works
Week numbering is where hand-made totals go wrong (which week does 30 December belong to?). Keeping an ISO week column next to the date makes the grouping explicit and repeatable: the same question gives the same rows every time.