calculation Monthly expense

Comments

4 comments

  • Mitchell Ogden

    Using reports you can accomplish this for this month and last month quite easily.

    Check out these resources:

    https://help.podio.com/hc/en-us/articles/204206708-Video-App-views-and-reports
    https://help.podio.com/hc/en-us/articles/201019638-Views-filters-and-reports

    You would create 2 views:

    One filtering the date field for current month

    One filtering the date field for last month

    I don't know if it would be worth coding this in a calculation field since reports makes it so easy.

    Mitch Ogden
    LevlUp

    0
    Comment actions Permalink
  • Rainer Grabowski

    Hi Jacob,

    you can create a report in app view like Mitchell suggested, it's the fastest and easiest way.
    If you want it in a calculation field in the categories app you can do some nice things, e.g you can define the report period as you like.

    Create in the Expense Categories App 2 date fields:
    Report StartDate
    Report EndDate

    The code in the calculation field:

     var exp = @all of expense  // the field with the amount;
     var expDate = @all of expense date;
     var start = moment(@Report StartDate).format("YYYYMMDD");
     var end = moment(@Report EndDate).format("YYYYMMDD");
    
     var reportAmount = 0
     for(var i = 0; i < exp.length; i++){
     if(moment(expDate[i]).format("YYYYMMDD") >= start && expDate[i]).format("YYYYMMDD") <= end){
     reportAmount +=exp[i]
     }};
     reportAmount 
    

    This shows you the amount of expenses in the chosen period.

    You can also define fixed periods, e.g. current month, last month, last 2 weeks, this year - as you like it. You don't need the date fields for it.

    2 Examples: Create a multi choice category field "Period" with categories (= fixed periods): current month, last month

    and 2 calculation fields.
    Calc field 1: current month

     var exp = @all of expense  // the field with the amount;
     var expDate = @all of expense date;
     var period = @period
     var periodDate = moment().format("YYYYMM")
    
     var curMonthAmount = 0
     for(var i = 0; i < exp.length; i++){
     if(period.indexOf(moment(expDate[i]).format("YYYYMM") ==  periodDate){
     curMonthAmount +=exp[i]
     }};
     period.indexOf( "current month") > -1 ? curMonthAmount : ""
    

    Calc field 2: last month

     var exp = @all of expense  // the field with the amount;
     var expDate = @all of expense date;
     var period = @period
     var periodDate = parseInt(moment().format("YYYYMM"),10)-1
    
     var lastMonthAmount = 0
     for(var i = 0; i < exp.length; i++){
     if(moment(expDate[i]).format("YYYYMM") ==  periodDate){
     lastMonthAmount +=exp[i]
     }};
     period.indexOf( "current month") > -1 ? lastMonthAmount : "" 
    

    You can use as many categories (periods) as you like. Everytime you select one of the categories the values will be updated. You can also have them all in one field. But if you have an own field for each period, you could create another app "Reports "with an own calculation field for each type of expense so that you have an overview of all expenses for a chosen period (which period you want to see, you can control in the "Report" app with a category field "Period" or with start/end Date fields - or with a combination of both).

    Rainer
    rg@delos-consulting.com

    1
    Comment actions Permalink
  • Jacob Edison VA

    Thank you Rainer! :)
    That looks complicated. i'll try to understand and use that.

    0
    Comment actions Permalink
  • Rainer Grabowski

    Hi Jacob,

    believe me, it isn't complicated :) Looks only complicated. You could copy my code and paste it into a calculation field. You only have to change the @fieldnames to your field names.

    Rainer

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk