Need help with calculating the Sum of 'Sales' per quarter (3 months)

I’ve searched the forum and haven’t been able to solve the problem yet.

For context, I’m making a CRM and in the ‘Dashboard’ page, I need to add the ‘Rolling Pipeline’ I.e., total Pipeline (solved), and the Pipeline per-quarter from a repeating group.

Data structure:
Prospect

  • Close date
  • Amount (deal size)

The calculation needs to consider the total amount of pipeline for this current quarter.

Any help would be hugely appreciated! TIA

What’s the problem you are currently facing? An expression error or a wrong operation result?

I feel you lack a :each item operator right after the merge operation. Difficult to say, I’m just thinking without trying in my editor.

1 Like

Hi, I appreciate the response. I’ve set the ‘close dates’ for the ‘Accounts’ at different dates ranging from 2024 - 2027. The sum is still calculating the Total Amounts for Accounts, rather than Amounts within the quarter

If you want to account for Prospects whose close date ranges from now to 3 months in the future, why do you need the merge operation? What’s in the result of the second Prospect search?

Hi, I have no idea why I put merge in there. It’s a combination of different thread posts/tutorials telling me how to do it. Any idea of the operations I’d need to do this? Is it more simple than I’m making it to be? (I’m 3 months into Bubble, so fairly new)

I guess I want to merge the ‘Total Amount’ I.e., deal sizes within a range of dates. So I assumed I’d merge the two together

I don’t know what Prospects you are getting in the second search, but you only need those retrieved by the first search.

Do the :sum operation over the amount of the Prospects that are retrieved by the first search and you’ll have it.

Disclaimer

The constraints in the search operation might be problematic though, since I can’t recall whether they conform an AND or OR operation. If it’s an AND you are good, if it’s an OR, you’ll indeed need two searches, each one with a different constraint, bound with an intersect operator


Hi, still no luck. Now it doesn’t display anything whatsoever!

Do you have Prospect records in your DB fulfilling the search contraints?
Is the search retrieving any record?

Hi, sorry for dragging this out btw! It’s started to pull a number with this operation


Not sure what this ‘£365,000’ is being calculated from to be honest.. I’m trying to calculate between set periods (quarter) I.e., from January - March, April - June, July - September, Oct-December.

Is there a way I can do this? I’m really struggling here lol

It’s all about how you define the Search for Prospects expression and its constraints.

If you are looking for natural quarters, as you stated, the current constraint won’t give the result you look for. As per your last screenshot, you are calculating the aggregated Prospect's amount for Prospects whose close date is later than 3 months in the future.

You should define constraints such as close date ≥ (Jan 1st 2025) AND close date ≤ (Mar 31st 2025)

You can have a look at this topic to learn how to group search results per quarter.

That makes sense, thank you very much for your help. Ademiguel! One quick question before I stop pestering you. Where do I type in (Jan 1st 2025) on this section? Or, is there somewhere I can select that date?

This was just pseudo-code, you can’t write it this way directly.

Just have a look at the link I provided in my previous post and play around a bit. If you don’t get it we can dive in again.


I made some progress with the :groupby function and have selected Q1 as the first example. I can’t however, link this new date interval to the sum of ‘deal-sizes’ relating to that quarter?

My god. We’ve got it!

Thank you @ademiguel!!!

Happy to help :slight_smile:

Although I do have one last question although you’re likely sick of me by now!

This works to show the Current Quarters pipeline. Once we go into the next quarter (April), how do I get the sum to automatically show that?

As an example, when I add the next 3 months from Apr - Jun, it sums the total from Jan - Jun?

You’ll have to define 4 different expressions for the Text value, one per quarter, and place them in conditionals in the Text’s conditionals tab. Just place conditions to make use of one of the 4 expressions, to discern whart quarter we are in currently, based on the Current time/date.

Got it, thank you. When I add the 4 quarters, I can no longer set an ‘end date’ for each quarter? Is this where I need to set the ‘End date’ to the end of the year as the ‘start date’ + 3 month interval already calculates per-quarters end date?