Find the difference in forecast and revenue in first quarter and distribute the difference amount

Find the difference in forecast and revenue in first quarter and distribute the difference amount to rest of the quarter's forecast 

For eg: forecast for Q1,2,3,4 is 1M each and sales bring up revenue of 800k in first quarter then the difference 200k should be distributed to rest of the quarter's for cast so Q2,3,4 forcast will be 1.066 M each

Here is what i have built (logic):

(SUM(CASE when QUARTER(`revenueDateEST`)<=QUARTER(CURDATE()) AND YEAR(`revenueDateEST`)=YEAR(CURDATE()) THEN `DisplayBase Quota` ELSE 0 END)

- SUM(CASE when QUARTER(`revenueDateEST`)<=QUARTER(CURDATE()) AND YEAR(`revenueDateEST`)=YEAR(CURDATE()) THEN (CASE when `Product`='DisplayBase' then `Revenue`else 0 end) ELSE 0 END))

/ (CASE WHEN (4-QUARTER(CURDATE()))>0 THEN (4-QUARTER(CURDATE())) ELSE 1 END)

+sum((CASE when QUARTER(`revenueDateEST`)=QUARTER(CURDATE())and YEAR(`revenueDateEST`)=YEAR(CURDATE()) then `Quota`else 0 end))

But, this is not working as expected, could anyone help with the code for the above, thanks in advance.

Tagged:

Answers

  • Adithya a screenshot of how you set up your beast mode would help.

    I suspect you have Q1,2,3,4 on the axis. If so then you canot use your beast mode because in Q2 i need to know the data that was in Q1,3 and 4 in order to answer the question.

    therefore you must use a cumulative sum (which is a window function) to begin addressing the question.

    sum(sum(amount)) over (order by date asc)

    I suspect what you need to do is take the cumulative sum of the revenue. subtract the cumulative sum of the base quota, and then average that out over the remaining quarters.

    Jae Wilson
    Check out my 🎥 Domo Training YouTube Channel 👨‍💻

    **Say "Thanks" by clicking the ❤️ in the post that helped you.
    **Please mark the post that solves your problem by clicking on "Accept as Solution"
  • @jaeW_at_Onyx as i explained in the question already, forecast/quota for Q1,2,3,4 is 1M each and sales bring up revenue of 800k in first quarter then the difference 200k should be distributed to rest of the quarter's forecast/quota so Q2,3,4 forcast will be 1.066 M each

    Please see the formula which i used in question so that you would know what are the field names used, please let me know if you need any more inputs. thanks for replying to my conversation.