Revenue by calendar month
Your task
Given orders with columns order_id, customer, amount, status and placed, sum amount for each calendar month. Return month as a YYYY-MM string and total, sorted by month ascending.
Examples
monthly_total(orders: dataframe) -> dataframeExample 1
Input
monthly_total(orders)orders
| order_id | customer | amount | status | placed |
|---|---|---|---|---|
| 1 | ada | 120.5 | paid | 2024-01-05 |
| 2 | bo | 80 | refunded | 2024-01-07 |
| 3 | ada | 45.25 | paid | 2024-02-11 |
| 4 | cy | 200 | paid | 2024-02-14 |
| 5 | bo | 15.75 | pending | 2024-03-02 |
| 6 | ada | 60 | paid | 2024-03-19 |
Output
| month | total |
|---|---|
| 2024-01 | 200.5 |
| 2024-02 | 245.25 |
| 2024-03 | 75.75 |