// Filter records based on the selected FrameID
ClearCollect(CollPerct, Filter('FAG Sheet Measured', FID = DataCardValue1.Text));
// Calculate the sums and percentages
Set(VarFAGPosSum, Sum(CollPerct, PositionScore));
Set(VarFAGFlushSum, Sum(CollPerct, FlushScore));
Set(VarFAGBothSum, Sum(CollPerct, BothScore));
Set(VarRowsCount, CountRows(CollPerct));
Set(FAGPosPerct, VarFAGPosSum / VarRowsCount);
Set(FAGFlushPerct, VarFAGFlushSum / VarRowsCount);
Set(FAGBothPerct, VarFAGBothSum / VarRowsCount);
// Update respective columns of all filtered rows with the calculated percentages
ForAll(
'FAG Sheet Measured',
Patch(LookUp('FAG Sheet Measured',FID=DataCardValue1.Text),
{ FAGPos: FAGPosPerct, FAGFlush: FAGFlushPerct, FAGBoth: FAGBothPerct }
)
);