Simplifying Small function with unknown K

MHJ17

New Member
Joined
May 18, 2022
Messages
1
Office Version
  1. 365
Platform
  1. MacOS
Hi,
I am looking for a method to simplify my function, which I have seen to work fine, but is slowing down my sheet drastically since it is used for a lot of cells.

I am using my workbook to show the Cost of Goods Sold (COGS), and basing my calculation on a data sheet containing all incoming products:
Example of the data sheet (incoming products):
Order NO - Product Name - Incoming date - Qty - Value
Order 1 - Product A - 2022;01;01 - 30 pcs. - $100
Order 2 - Product A - 2022;02;01 - 40 pcs. - $104
Order 3. - Product A - 2022;03;01 - 20 pcs. - $95
Order 4. - Product A - 2022;04;01 - 70 pcs. - $101

The function I use asks: IF("Items sold until X date"<Index("Value";Small(If("Product Name"="Product A";Row("Incoming Date"));1)))

This function is short when asking for the first order of product A, but when I ask for order no. 10 it looks like this:
=IF(9000<
INDEX('Master incoming'!$J:$J;SMALL(IF('Master incoming'!$G:$G='Inventory overview'!APT$2;ROW('Master incoming’!$S:$S));10))+
INDEX('Master incoming'!$J:$J;SMALL(IF('Master incoming'!$G:$G='Inventory overview'!APT$2;ROW('Master incoming’!$S:$S));9))+
INDEX('Master incoming'!$J:$J;SMALL(IF('Master incoming'!$G:$G='Inventory overview'!APT$2;ROW('Master incoming’!$S:$S));8))+
INDEX('Master incoming'!$J:$J;SMALL(IF('Master incoming'!$G:$G='Inventory overview'!APT$2;ROW('Master incoming’!$S:$S));7))+
INDEX('Master incoming'!$J:$J;SMALL(IF('Master incoming'!$G:$G='Inventory overview'!APT$2;ROW('Master incoming’!$S:$S));6))+
INDEX('Master incoming'!$J:$J;SMALL(IF('Master incoming'!$G:$G='Inventory overview'!APT$2;ROW('Master incoming’!$S:$S));5))+
INDEX('Master incoming'!$J:$J;SMALL(IF('Master incoming'!$G:$G='Inventory overview'!APT$2;ROW('Master incoming’!$S:$S));4))+
INDEX('Master incoming'!$J:$J;SMALL(IF('Master incoming'!$G:$G='Inventory overview'!APT$2;ROW('Master incoming’!$S:$S));3))+
INDEX('Master incoming'!$J:$J;SMALL(IF('Master incoming'!$G:$G='Inventory overview'!APT$2;ROW('Master incoming’!$S:$S));2))+
INDEX('Master incoming'!$J:$J;SMALL(IF('Master incoming'!$G:$G='Inventory overview'!APT$2;ROW('Master incoming'!$S:$S));1));10;"")


Is there any way to shorten this in any way?

Thank you in advance

Best
Morten
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
77,713
Office Version
  1. 365
Platform
  1. Windows
No idea what you are trying to do, but maybe
Excel Formula:
=LET(f,FILTER('Master incoming'!$J:$J,'Master incoming'!$G:$G=APT$2),IF(9000<SUM(INDEX(f,SEQUENCE(MIN(10,ROWS(f))))),10,""))
 

Forum statistics

Threads
1,176,122
Messages
5,901,505
Members
434,898
Latest member
dez091

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
Top