counting last 5 days

13 posts / 0 new
Last post
Joshua
Offline
Joined: 07/03/2017 - 07:11
counting last 5 days

i'm looing for somthing that keeps counting the last 5 days per id.
so from the fifth row, while the id is the same, i add the "amt" but if the "id" changes, it starts again.
for ex.
 

Images: 
Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Hi Joshua,

Interesting problem, I should be able to figure it out in a script.  Thanks for posting an image as it helps when trying to create something.  I will get back to you when I have something for you to try.

Brian

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Hi Joshua, for your question, is it possible that you can have the same date multiple times for the same ID? or will it always be a separate date per item?

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Hi Joshua,

I have something for you but I am waiting to hear if there can be multiple dates for the same ID.  If there is then that complicates the script a fair amount so let me know.

Thanks

Brian

Joshua
Offline
Joined: 07/03/2017 - 07:11

hi Brian,
weird.. i'm almost sure i posted a comment here but i don't see it anymore :|
for every ID there's only one row per date.
the idea is to check for every ID , for the all year (jan- dec ) the amount for seven days in a row ( i notice i wrote 5.. but i ment 7 days )
sorry for the delay and thank you for your help
Joshua

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Hi Joshua,

Thanks for getting back to me and the clarrification.  I will get back to you when I have the script ready.

Brian

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Hi Joshua, just to let you know I haven't forgotten about you.  Work has been quite busy and I haven't had any extra time to complete this.

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Hi Joshua,

Here is a script for you to try out.  You have to select the ID, the date fields (needs to be in date format) and the amount.  It creates a sorted database and then calculates the field based on the id and date field.  Let me know if you find any problems with it.

Thanks

Brian

Joshua
Offline
Joined: 07/03/2017 - 07:11

Thank you Brian!
I get this error and the cursor is where the yellow line on the script
Thanks,
Joshua

Images: 
Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Hi Joshua,

I updated the file, I forgot to change the hard coded field names for the variables.  I changed that so it should work for you now.

Brian

Joshua
Offline
Joined: 07/03/2017 - 07:11

Hi Brian,
it appears that the "sum" field doesn't do the job well.. look at the image..
on the fifth row the "sum" starts again (instead on the 8 row sums rows 2-8, and  row 9 sums 3-9 and so on..)
 
Thanks again for all your help!!! :)

Images: 

Pages