Forum Discussion
Patrick2788
Jun 25, 2022Silver Contributor
A LAMBDA Exercise
For this exercise I stripped down a calendar template and put in some sample data. The goal is to obtain gross pay for July for 3 employees. The data arrangement: I believe there are seve...
SergeiBaklan
Jun 25, 2022MVP
As variant
weekdayMultiplier=
LAMBDA( weekday, CHOOSE(weekday, 1.5, 1, 1, 1, 1, 1, 1.5) );
weekdayHours=
LAMBDA( vector, weekday,
SCAN(0, vector,
LAMBDA(a,v,
IF( v= 4, 16, // with simplified holidays
IF( v = "", 0,
IF( ISTEXT(v), a, 8*weekdayMultiplier(weekday)) ) ) ) )
);
weekdayPersonHours=
LAMBDA( vector, weekday, name,
SUM( weekdayHours(vector, weekday)*(vector=name) ));
monthPersonHours=
LAMBDA( month, name,
REDUCE(0, SEQUENCE(7), LAMBDA( a,v,
a + weekdayPersonHours( CHOOSECOLS( month,v), v, name) ))
);
GrossPay=
LAMBDA( month, names, rates,
SCAN(0, names, LAMBDA(a,v, monthPersonHours(month, v) ) )*
rates
);