Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

261
Views
Is there any way to aggregate a model based on date range (i.e monthly aggregation) on dynamo db with graphql?

I am using amplify cli having dynamo database along with GraphQL API. I have a sales model which keep sales record i.e sale amount along with the date. I want to aggregate the sales amount for each month in a year to show the sales statistics on a graph which show total sales made in each month over the year. Currently I am using GraphQL queries to query/search data from the backend.

Here is the model that I am using.

type Sales @model @searchable @auth(rules: [{ allow: private }]) {
id: ID!   
userID: String! @index(name: "byAdded", sortKeyFields: ["createdAt"])   
createdAt: AWSDateTime!   
saleAmount: Float
}

Here is the example usage of graphQL query that I am currently using to get a aggregated amount for the whole year.

await API.graphql(
        graphqlOperation(searchSales, {
          filter: {
            and: [
              { userID: { eq: userId } },
              { createdAt: { range:["2022-01-01", "2022-12-31"] } },
            ],
          },
          aggregates: {
            type: 'sum',
            field: 'saleAmount',
            name: 'totalSales',
          },
        }),
      );

Currenty Query result:

{"aggregateItems": [{"name": "totalSales", "result": {"value": 4608} }], "nextToken": "WyIwZTUyNmY2JkMjUiXQ==", "total": 7}

I want to have a result like following:

aggregations : { jan: 234, feb: 343, march: 3465, ...... } 
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!