Sum Monthly Revenue based on Date Fields

Comments

7 comments

  • Rainer Grabowski

    Hi Mike,

    is there always only one Sales App item related to the P&L-item where you want to calculate the revenue or shall it calculate the revenue from multiple Sales items? For both options your code is wrong.

    Btw: The line var datei doesn't make sense there. Take it out of the loop, remove [i] and add it to the other vars:
    var date = @Reporting Period

    Rainer

    1
    Comment actions Permalink
  • Mike Markiewicz

    Hi Rainier,

    There are multiple sales items, each with their own payout options (some pay out one time, some quarterly, some monthly). Thank you for your help!

    1
    Comment actions Permalink
  • Rainer Grabowski

    Hello Mike,

    I've asked if there's one or multiple items related, cause that determines the vars start and and. If multiplie (like in your case) you can't use @max of date - cause this pulls the max date of all items (3 items with dates 09/08/2107, 09/09/2017, 09/10/2017 -> max = 09/10/2017). But what you want to get, is start and end of each item to compare each item to the Reporting date. This said you need 

    var amt = @All of Comission Data Amount;
    var start = @All of Comission Start;
    var end = @All of Comission End;
    var date = moment(@Reporting Period);
    var sum = 0;
    for(var i = 0; i < amt.length; i++){
    if(moment(start[i]) <= date && moment(end[i]) >= date){
    sum += amt[i] || 0;
    }
    };
    sum

    Rainer

    0
    Comment actions Permalink
  • Mike Markiewicz

    Hi Rainier,

    Thank you for your help, but it's still showing "0" under Revenue Calculation. What information can I provide you to get a resolution? Also, can Podio search the entire Sales App without having to link each individual sale item from the Sales App in the Revenue Link field in the P&L App?

    0
    Comment actions Permalink
  • Dan Stroehlein

    Did you ever determine a solution on adding the sum based on a date range?

    0
    Comment actions Permalink
  • Rainer Grabowski

    Hi Dan,

    yes, multiple times. What exactly is your use case?

    Rainer

    0
    Comment actions Permalink
  • Dan Stroehlein

    Rainer,

    I have a monthly report app and I have an income and expense app.  I want to sum the income for the date specified in the report (2 separate date fields, one is the report start and the other report end).  I will do the same for the expenses.  Any help is appreciated, or even if you link me to the solution, thanks again!

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk