Hi Guys,
I am having difficulty calculating the employee leave balance based on leave type, I have created two tables one containing employee leave information: employee name lookup field, email lookup field start date, end date, and number of days applied, The Leave balance table contains annual leave,flexi leave, employee name and email. the employee will enter the information using the form
and I have already added the code for calculating the number of leaves applied

With(
{
// generate a one-column table of all dates between start date & end date
varDateRange: ForAll(
Sequence(DataCardValue17.SelectedDate - DataCardValue16.SelectedDate + 1),
DataCardValue16.SelectedDate + Value - 1
)
},
If(
And(
IsBlank(DataCardValue16.SelectedDate),
IsBlank(DataCardValue17.SelectedDate)
),
// show nothing if any date pickers are blank
0,
// show only dates Sunday to Thursday and exclude holidays
CountIf(
varDateRange,
And(
Weekday(Value) in [1, 2, 3, 4, 5],
Not(Value in 'Public holidays'.Date)
)
)
)
)
I want to calculate the leave type like this he will select the leave type for the drop-down box which is datacardvalue22 then it will be subtracted based on leaves applied by the user
sample code below
Set(varAnnualLeave,(LookUp('Leave Balance','Email'.Value=User().FullName).Annual));
Set(VarFlexiLeave,(LookUp('Leave Balance','Email'.Value=User().FullName).Flexi));
Set(VarsickLeave,(LookUp('Leave Balance','Email'.Value=User().FullName).sick));
used lookup to view each employee's leave balance
If(DataCardValue13.Selected.Value="Annual Leave")
varAnnualLeave-datacard.text
else if
flexi
varFlexiLeave-Datacard22.text