Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
veldetta
Contributor III
Contributor III

Sum of amount for last 6 Months from particular date within table

My sample data/table looks like such:

    

MonthCompanyPromiseActual
Jan-15ABC $10
Feb-15ABC $20
Mar-15ABC $30
Apr-15ABC $40
May-15ABC $50
Jun-15ABC $60
Jul-15ABC $70
Aug-15ABC$50$80
Sep-15ABC $0
Oct-15ABC $0
Nov-15ABC $0
Dec-15ABC $0
Jan-16XYZ $10
Feb-16XYZ $20
Mar-16XYZ $30
Apr-16XYZ $40
May-16XYZ $50
Jun-16XYZ$40$60
Jul-16XYZ $70
Aug-16XYZ $80
Sep-16XYZ $0
Oct-16XYZ $0
Nov-16XYZ $0
Dec-16XYZ $0

I would like to calculate the the sum of the amount for the past 6 months from the date of the promise for each company. 

So for Company 'ABC', I would like to show $300 and for Company 'XYZ', I would like to show $210.. either by adding a new column or performing a set analysis in a chart.  I've spent a few hours trying to figure this out and i haven't gotten far. 

Thanks guys.

Regards,

Vel

8 Replies
hirenjadiya
Partner - Contributor III
Partner - Contributor III

Hi,

Looking at the data it seems for Company 'ABC' the total should be $330 instead of $300

(

15-MarABC $30
15-AprABC $40
15-MayABC $50
15-JunABC $60
15-JulABC $70
15-AugABC$50 $80

)

CORRECT?

Anil_Babu_Samineni

LET vDate = '20-01-2016'

LET vParticulatrDate = Date(monthstart(Makedate('$(vDate)',1),-6))


Here, Date should be your fixed date.

Sum({<Comapny = {'ABC'}, Date = {'$(vParticulatrDate)}>} Amount)

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
veldetta
Contributor III
Contributor III
Author

Correct!  my error...

veldetta
Contributor III
Contributor III
Author

Thanks... this helps somewhat.  However, I will need vDate to be dynamic as each company would have a different vDate.

rupamjyotidas
Specialist
Specialist

Maybe Something like this

if(Len(Promise)>0 ,RangeSum(Above(SUm(Actual),0,6)))

veldetta
Contributor III
Contributor III
Author

I would like for my output to be:

   

CompanyPromiseActual (6 months)
ABC$50$330
XYZ$40$210
veldetta
Contributor III
Contributor III
Author

I like this but I will need to use date as there could be more than 2 entries for in a month and I need to capture those as well.

rupamjyotidas
Specialist
Specialist

Something like this

Sum({<Month={">date(AddMonths(Month1,-6),'MMM-YY') <=date(AddMonths(Month1,0),'MMM-YY')"}>} Actual)

Where Month1 is

Date(If(Len(Promise)>0,Month),'MMM-YY') as Month1