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...
Patrick2788
Jun 26, 2022Silver Contributor
I think I made this exercise too easy. mtarler struck it with a blunt instrument (COUNTIFS) and got the job done. PeterBartholomew1 - I thought I made this one a pain with the holiday pay but you seem to have resolved this one easily working COUNTIFS into your LAMBDA.
I believe SergeiBaklan has a solution that can be scaled to include 3D referencing.
I had to do it. I've updated the workbook, so it now includes 3 months. I've made some design changes: the number for the day of the week is now a true date and a list of holidays is included in the summary sheet.
SergeiBaklan
Jun 27, 2022MVP
Yes, there are minor adjustments in previous solution to work with few months. The only, I have a bit different result with you. Calculated weekend hours for Bev
Didn't dig what and where exactly is wrong.
- Patrick2788Jun 27, 2022Silver Contributor
Thanks for catching that one.
I feel silly:
(I've replaced the workbook previously uploaded)
- mtarlerJun 28, 2022Silver Contributor
Patrick2788 without those new beta functions it seems harder (at least to me) so I added the sheet names and made a 2 level BYROWS() call:
=BYROW(staff,LAMBDA(e, SUM(BYROW(SheetNames, LAMBDA(mm, LET(sm, INDIRECT(mm&"!a3:g20"), swd, INDIRECT(mm&"!b3:f20"), smb, INDIRECT(mm&"!a4:g21"), smc,INDIRECT(mm&"!a5:g22"), 1.5*COUNTIF(sm,e)-0.5*COUNTIF(swd,e) +SUM(COUNTIFS(sm,holidays,smb,e)+COUNTIFS(sm,holidays,smc,e)) ) ))) ))*8*rate
- Patrick2788Jun 28, 2022Silver Contributor
It's certainly a good solution with Beta functions not available. Use of INDIRECT is not ideal but the workbook is not large enough where there might be a calculation crunch.
- SergeiBaklanJun 27, 2022MVP
Now we are in sync
- Patrick2788Jul 02, 2022Silver ContributorThank you for sharing. The way you approach this task is fascinating. The way I was taught to write code in VBA is avoid lengthy modules and split subroutines in smaller tasks and simply call them in another macro. Your LAMBDAs are like a quality Dutch coffee maker. If one part needs to be removed or replaced, it's easy to do so. Additionally, I do like the parameter names like 'vector' instead of single 'x' or 'y', for example.