
Steen Olsen asked a question.

Steen Olsen asked a question.

@Steen Olsen are you referencing the app to register revenue from another app like "clients?" (A client item has a relationship to one more more items in the app where you're tracking revenue?)

@Joel Hall yes I am. I have my CRM-app containing general info about a client and the an app called “Timer” (= billed hours), that contains a relation to the client, the qty of hours, a rate
per hour and a revenue field (hours x rate).
I want to pull the accumulated revenue per client for the past 365 days rolling

@Steen Olsen There are two different 'year' date filters: "Year" and "Last calendar year". If you select "Year" then it will be rolling, e.g. that filter today would be 3/6/2024-3/6/2025 and would update each day.

Thanks - I tried to do that and it works when I use the filter feature, but not when I am using calculations. I used ChatGPT which suggested this calculation script but it doesn't calculate right, which I believe it should. Can you help me more?
***
var LastYear = moment().subtract(365, 'days');
var Dates = @All of Fastpris - Faktureringsdato; // Invoice date
var Revenue = @All of Fastpris - Faktureringsbeløb; // Invoice amount
var total = 0;
for(var i = 0; i < Dates.length; i++) {
var dato = moment(Dates[i]);
if(dato.isAfter(LastYear)) {
total += Revenue[i] || 0;
}
}
total
***

@Steen Olsen I think the issue you're going to run into is that Podio's calculation fields won't update unless there is another field change (they do not update based on time passing). In order to do this, you'll want create an app somewhere called "Today" with a single item that contains a date field. You'll then want a workflow that runs daily to update the date field in that specific item to the current date (basically that individual item will always contain the current date). You'll then need to relate your client items to that "Today" item (probably through a workflow when each client record is created). Once that relationship is made, your client app will be able to see the current date from the Today app to be used in the calculation that would then look like this...
var currentDate = moment(@THIS WILL BE THE DATE FIELD PULLED FROM TODAY APP);
var lastYear = currentDate.subtract(365, 'days');
var dates = @All of Fastpris - Faktureringsdato;
var revenue = @All of Fastpris - Faktureringsbeløb;
var total = 0;
for (var i = 0; i < dates.length; i++) {
var dato = moment(dates[i]);
if (dato.isAfter(lastYear)) {
total += revenue[i] || 0;
}
}
total;

@Steen Olsen This is it! Feel free to shoot me an email if you need any help setting this up: jacquelyn.may@zooli.io.

@Steen Olsen, Jacquelyn is an amazing partner to work with. She can help you get this setup in no time.
@Steen Olsen I think the issue you're going to run into is that Podio's calculation fields won't update unless there is another field change (they do not update based on time passing). In order to do this, you'll want create an app somewhere called "Today" with a single item that contains a date field. You'll then want a workflow that runs daily to update the date field in that specific item to the current date (basically that individual item will always contain the current date). You'll then need to relate your client items to that "Today" item (probably through a workflow when each client record is created). Once that relationship is made, your client app will be able to see the current date from the Today app to be used in the calculation that would then look like this...
var currentDate = moment(@THIS WILL BE THE DATE FIELD PULLED FROM TODAY APP);
var lastYear = currentDate.subtract(365, 'days');
var dates = @All of Fastpris - Faktureringsdato;
var revenue = @All of Fastpris - Faktureringsbeløb;
var total = 0;
for (var i = 0; i < dates.length; i++) {
var dato = moment(dates[i]);
if (dato.isAfter(lastYear)) {
total += revenue[i] || 0;
}
}
total;