Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I have the following table that shows a schedule of payements
ID Payement Date Amount Most Recent payement
1 3/1/2012 800 1000
1 5/1/2012 1000 1000
1 6/1/2012 1000 1000
1 10/1/2012 1000 1000
2 1/1/2010 300 500
2 6/1/2012 500 500
2 8/1/2012 500 500
3 4/1/2011 300 1000
3 5/1/2012 1000 1000
3 12/1/2012 1000 1000
I need to calculate a new field to show the most recent payement.(The red field ).
the calculation should look at today's date and compare it to the the date field(Month/Year) and then put the amount of that row in a new field next to the ID.
I Am not sure how to do it..and i have' been thinking about it all day.
I appreciate any help..
Thxs,
temp:
LOAD ID,
[Payment Date],
Amount
FROM....;
Data:
LOAD
ID
,LastValue([Payment Date])
,LastValue(Amount)
RESIDENT temp
WHERE [Payment Date] <= Today()
GROUP BY ID ORDER BY [Payment Date];
DROP TABLE temp;
See attached.
In other words,
I don't mind having a table with
ID Date Most recent Payement
1 6/1/2012 1000
2 6/1/2012 500
3 5/1/2012 1000
Thxs,
Does the answer need to be based on current selections?
Hi,
Not necessarily.
If i could get it without current selection then it is fine.
I also have a field that i would like to filter by.
The filter field name is xyz and the value that i am looking to filter by is A.
Thanks so much for your help,
Alec
If that filter is user-applied then you can't do it in the script.
Have you tried using FirstSortedValue()? I think you'll need to use Aggr() in the second parameter.
Jason
The filter is not user- applied.
Not sure how to do that.
Thxs,
Try:
LOAD
ID,
Date,
LastValue(Payment) AS LastPayment
Resident PreviousTable
GROUP BY ID,Date
ORDER BY ID, Date;
Hope this helps,
Jason
Actually I think that's slightly wrong:
LOAD
ID,
LastValue(Date) AS Date,
LastValue(Payment) AS LastPayment
Resident PreviousTable
GROUP BY ID
ORDER BY ID, Date;
Hi,
Last value will bring the last date value which is 10/1/2012 in ID 1
I am looking for the most recent which should bring 6/1/2012.
Thxs
ORDER BY ID, Date DESC