I am trying to get the percentage of Total Check Ins and Check Outs out of Total Appointments and it's working but when I open my powerapps through sharepoint it gives me this error, "Invalid Operation: division by zero." If anyone can help me fixing it, I would really appreciate it.
This is my code on the OnStart property of Screen:
ClearCollect(
colAppointmentsWithoutRN,
Appointments
);
ClearCollect(
colAppointments,
ForAll(
Sequence(CountRows(colAppointmentsWithoutRN)),
Patch(
Last(
FirstN(
colAppointmentsWithoutRN,
Value
)
),
{RowNumber: Value}
)
)
);
Set(
varRowsPerPage,
7
);
Set(
varCurrentPage,
1
);
Set(
varTotalPages,
RoundUp(
CountRows(colAppointments) / varRowsPerPage,
0
)
);
Set(
isTimerStart,
true
);
Set(
varStartTimer,
true
);
// Gallery Code Ends
Set(
varDistVARep,
Distinct(
colAppointments,
'VA Representative'
)
);
ClearCollect(
colAppointmentsWithDiff,
AddColumns(
colAppointments,
"TimeDifference",
DateDiff(
'Check-in time',
//'Checkout time',
'Appointment-Ends',
TimeUnit.Minutes
)
)
);
Set(varTotalTimeDifference, Sum(colAppointmentsWithDiff, TimeDifference));
Set(
varTotalRep,
CountRows(varDistVARep)
);
Set(
varTotalAppointments,
CountRows(colAppointments)
);
Set(
varTotalCheckIn,
CountRows(
Filter(
colAppointments,
Status.Value = "Checked-in"
)
)
);
Set(
varTotalCheckOut,
CountRows(
Filter(
colAppointments,
Status.Value = "Checked-out"
)
)
);
Set(
varCheckInPercet,
Text(varTotalCheckIn / varTotalAppointments) * 100 & " %"
);
Set(
varCheckOutPercet,
Text(varTotalCheckOut / varTotalAppointments) * 100 & " %"
);
Clear(colPiCharData);
Collect(
colPiCharData,
{
Status: "Check In",
Count: varTotalCheckIn
}
);
Collect(
colPiCharData,
{
Status: "Check Out",
Count: varTotalCheckOut
}
);
And here is the error again:
