Spilling Total using different ranges & If statement

bearcub

Well-known Member
Joined
May 18, 2005
Messages
734
Office Version
  1. 365
  2. 2013
  3. 2010
  4. 2007
Platform
  1. Windows
I am using the following formula to spill total commissions earned for our reps:

BYROW(I8:N86,LAMBDA(r,IF(Q8="Commission",SUM(r,K8:N8),J8)))

1716820910337.png


It works great except for paying someone a draw.

Column I are commissions earned based upon a data dump from our commissions software program. This column represents earning based upon new business for the month of April

Column J is a monthly draw paid to new hires. Our company policy states that the rep will be paid the larger of the draw or earnings amount. This rep should be paid 15K not 19K as shown in O11.

Note that I have a formula in column Q to allow either commission or draw to be diplayed. This is to let me know that a rep should be paid the draw amount and not the Commissions.

The formula "IF(Q8="Commission",SUM(r,K8:N8),J8)", without using ByRow & Lambda ,has worked up to now. When I us ByRow & Lambda the IF condition seems to be ignored -- probably because I am using Column J in the ByRow formula.

I substituted MAP for BYRow I get this. I just learning how to using the array functions so I realize that I don't totally understand how they are to be used.

What am I doing wrong.

Thank you for your help in advance.


1716821856657.png
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Will col J be blank if it's commission?
 
Upvote 0
Yes, J is only used for Draws (commissions never show up in this column, only draws).

f the rep had earned 16K instead of 4K then the draw would be ignored and the 16K would be paid. Reps are paid either the draw or earnings, which is larger.
 
Upvote 0
Ok, how about
Excel Formula:
=BYROW(CHOOSECOLS(I8:Q100,1,2,3,4,5,6,-1),LAMBDA(br,IF(TAKE(br,,-1)="draw",MAX(CHOOSECOLS(br,2),CHOOSECOLS(br,1)),SUM(br))))
 
Upvote 1
Solution
Works like a charm, thank you. How did you know that Choose columns would work instead of MAP
 
Upvote 0
With the map function all ranges need to be the same size.
 
Upvote 0
Oh, I see. Kinda like using the Index function where the arrays all have to be the same size.
 
Upvote 0
A slightly shorter version
Excel Formula:
=BYROW(CHOOSECOLS(I8:Q100,1,2,3,4,5,6,-1),LAMBDA(br,IF(TAKE(br,,-1)="draw",MAX(CHOOSECOLS(br,1,2)),SUM(br))))
Kinda like using the Index function where the arrays all have to be the same size.
With Index the arrays/ranges do not need to be the same size.
 
Upvote 0
What does the Take Function do in this formula? Looking at it, it looks like it is looking the first 2 columns of the array
 
Upvote 0
It's returning the last column in the array.
 
Upvote 0

Forum statistics

Threads
1,223,950
Messages
6,175,582
Members
452,653
Latest member
craigje92

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top