Calculate Total Gross Sales from GraphQL API

Calculate Total Gross Sales from GraphQL API

guillaume_
Visitor
1 0 0

Hi everyone,

 

I'm trying to calculate the previous day's total gross sales in Shopify using the GraphQL orders query, aiming to match the totals from Shopify's Total Sales report or the shopifyqlQuery results.

 

The shopifyqlQuery provides accurate results but only after a full 24-hour delay. When querying gross_sales and discounts for October 1st on the morning of October 2nd, it returns an incomplete figure that continues to update until midnight on October 3rd.

 

I need to calculate a near-final total using the GraphQL API's fields like subtotalPriceSet, totalDiscountsSet, totalTaxSet, taxRate, billingCountry, etc. for each order. Despite testing formulas by region (e.g., handling tax-inclusive/exclusive pricing), I haven’t been able to replicate the report’s figures.

 

Example formula attempts:

 

  • Sweden/Denmark (Tax-Inclusive): Gross Sales = (Subtotal Price - Total Discounts) / (1 + Tax Rate)
  • UK (Tax-Exclusive):
    • When Tax Rate > 0: Gross Sales = (Subtotal Price - Total Discounts) / (1 - Tax Rate)
    • When Tax Rate = 0: Gross Sales = Subtotal Price - Total Discounts
  • Canada/Others: Gross Sales = Subtotal Price - Total Discounts

Has anyone successfully matched these totals in near real-time? Any advice would be appreciated!

 

Thanks for your help,
Guillaume

 
 
Replies 0 (0)