Use the Sum ( ) function to get the total from your portal Sum ( YourRelatedLeaveDaysField ) . This will give you number of used days. Then have a field on the Users table that calculate
Users available leave days - Sum ( YourRelatedLeaveDaysField )
This will give you what is left to use
I am using a repeating field (Numberofdays).
and a formula, TotalAvailableDays- Sum(Numberofdays) however my field(showing the availabledaysleft) only shows the subtraction of the first equation and remains the same even when the user applies for more leave.
Off the top of my head, no computer at hand: I believe there is an extend() function to make repeating fields give corresponding values in repeating sum fields. Otherwise repeating fields don't work for this.
Like Stephan wrote, you can use the Extend ( ) function to sum repeated fields, but I recommend you to have a portal towards another table. It is way more flexible and more up to date working with related records in a portal then repeated fields