Compare sales between periods
compare_salesShopify's sales breakdown (gross sales, discounts, returns, net sales, total sales, orders) for a span AND its comparison period, line by line with change and changePct, already worked out; compared with the days before, sameTimeLastYear also gives the same dates a year ago, so a seasonal fall shows — the tool for 'why did sales fall', 'what happened against last year', 'compare these weeks with the same weeks last year'. netSalesGap splits the change in net sales into fromGrossSales, fromDiscounts and fromReturns (they add up to the total; negative = that part pulled net sales down) with each part's share of the gap; returnsShareOfGross gives returns ÷ gross in both periods and the change in points; grossPerOrder is gross sales per order; refunds is the NUMBER of refunds issued; traffic gives sessions and the site's conversion rate in both periods (null = no traffic source); customers gives new customers, returning customers and returning customers' orders in both periods. byWeek adds the same per 7-day week, plus lossDays (days whose net sales were below zero: refunds above sales) and weakestDays (the three lowest days). Shares of the gap can add up to more than 100% when discounts moved the other way: say so. grossDrivers (online) splits the change in gross sales into trafficEffect, conversionEffect and valuePerOrderEffect, which add up to grossChange: quote them to say whether fewer people came, fewer bought or each order was worth less. headline is the diagnosis's opening table, already in order: render EVERY row (translate the line names; a rate row's change is in points). These are the store's sales-ladder totals: get_sales_by's product-line netSales can differ by a few euros — quote this tool for store totals. Quote these figures: never subtract the two periods yourself. Returns count in the period the refund was issued, not the period of the order — say so when returns drive the change. complete false = some orders lack the figures and every line understates. Optional from and to (inclusive YYYY-MM-DD, both or neither, never after today) read another span instead of the default period. A named month, a week or two dates the operator gave MUST be sent here: without them this reads the last 30 days, which is not that month.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| to | No | Last day of the span, inclusive, as YYYY-MM-DD; not after today. Send together with `from`, or omit both to read the default 30-day period. | |
| from | No | First day of the span, inclusive, as YYYY-MM-DD. Send together with `to`, or omit both to read the default 30-day period. | |
| byWeek | No | Also split the span into 7-day weeks from its first day (start the span on a Monday for natural weeks), each compared with the same week of the comparison period. Up to 13 weeks. | |
| compare | No | What to compare the span with: previous (default, the same number of days just before), yoy (the same dates last year) or yoyWeekday (52 weeks back, the same weekdays — use it for natural Monday–Sunday weeks or whenever the operator says 'last year' over weeks). | |
| compareTo | No | Last day of the named comparison period, YYYY-MM-DD. | |
| compareFrom | No | First day of a NAMED comparison period, YYYY-MM-DD, with compareTo. For 'September with October': from/to October, compareFrom/compareTo the whole of September. Takes the place of compare. | |
| salesChannel | No | Only online orders (the web shop) or only point-of-sale orders; omit for every channel. When the operator says 'solo web', 'online only' or 'sin POS', send online — and keep sending it for the rest of the conversation. |