2.1 Fields pulled directly from Shopify
2.2 Fields pulled from Amazon fact table
3 Final Metrics
Metric label in final view
(Because the intermediate column names are reused, remember that the gross_sales inside this formula is the pre-tax product subtotal fetched from Shopify/Amazon.)
4 Customer and channel tagging (non-numeric but critical)
Channel — literal 'SHOPIFY' or 'AMAZON' assigned in each branch before the UNION. customer_tag — hierarchy applied to avoid duplication:
Explicit overrides: APOGEN (Shopify order tagged with Apogen) APOS&A (tagged APOS&A)
Mapped tiers (non-Apogen): S&A DISTRIBUTOR → DISTRIBUTOR → S&A → OTHERS → GENERAL (default). If multiple tags match an order, the ROW_NUMBER() window in ranked_shopify keeps the highest-priority tag and discards the rest.
5 Date handling
order_date is always computed as
DATE(TIMESTAMP(created_at), 'America/Los_Angeles')
ensuring that the reporting day matches the US-Pacific business calendar, regardless of the store’s native timezone.
6 Key take-aways / implementation reminders
Shopify test & migrated orders are removed upfront (test = FALSE, no Migrated_Orders tag). Fully refunded orders are excluded early by financial_status != 'refunded'; partial refunds still flow through as return_amount. Currency consistency – all Shopify amounts are in the shop currency by design, so you do not need forex conversions before combining with Amazon (which already reports in USD for the US seller account). To extend the model to other geographies, update the timezone in every DATE(TIMESTAMP()) call and revisit duties/additional-fees availability for Amazon.