Need Help simplifying a formula!

RICH937

Board Regular
Joined
Apr 15, 2023
Messages
59
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
Hi Excel people! I am sure I have overcomplicated this, but after 3 days of trying and failing to write a formula that works, this is where I landed. It works, but it's way too long, and is causing "calculate sheet" to take an extremely long time. An excel sheet with both the data I'm using and the steps I used to create the final formula is attached. The data I am using has 34 products sold in118 categories to ~10.5K customers. I need to identify a specific value for each product in each category associated with an adjusted %. The problem is the adjusted % occurs multiple times across products/categories. I have tried every XLookup, Index+Match, "If", and Filtering combination I could think of to ID the specific value by product+category, but every attempt I made returned an earlier instance. I finally ended up turning each Category + Product into an individual array, and then using index, filter, choosecols and xlookup to ID the correct value. It works, but it's insanely long.

Note: I couldn't get the mini-sheet to work. Both the "mini-sheet" and "table only" options were grayed out, so I uploaded the excel to my google drive. here's a link to the file folder. It should be set up to download or view in google docs: excel help - Google Drive
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Thought this might help too:
S.1 Formula: FILTER(CHOOSECOLS(INDEX($B$2:$G$21331,,),5,6),($B$2:$B$21331=B3)*($C$2:$C$21331=C3))
S.2 Formula: XLOOKUP((MIN(CHOOSECOLS(INDEX(J3#,,),1))),CHOOSECOLS(INDEX(J3#,,),1),CHOOSECOLS(INDEX(J3#,,),2))
S.3 Formula: XLOOKUP((MIN(CHOOSECOLS(INDEX((FILTER(CHOOSECOLS(INDEX($B$2:$G$21331,,),5,6),($B$2:$B$21331=B3)*($C$2:$C$21331=C3))),,),1))),CHOOSECOLS(INDEX((FILTER(CHOOSECOLS(INDEX($B$2:$G$21331,,),5,6),($B$2:$B$21331=B3)*($C$2:$C$21331=C3))),,),1),CHOOSECOLS(INDEX((FILTER(CHOOSECOLS(INDEX($B$2:$G$21331,,),5,6),($B$2:$B$21331=B3)*($C$2:$C$21331=C3))),,),2))

The third formula is the same as the second with the first formula swapped for every instance of J3#.

Really appreciate any help!
 
Upvote 0
excel sheet capture.PNG
 
Upvote 0
Have a look at this to see if it helps:
20230603_EXCEL HELP.xlsx
BCDEFG
1CATEGORY (C)PRODUCT (P)GROUP (G)QTYPERCENT (%)C+P COUNT
2CATEGORY 1PRODUCT 1GROUP 14020%1
3CATEGORY 1PRODUCT 2GROUP 220036%1
4CATEGORY 1PRODUCT 2GROUP 31502%2
5CATEGORY 1PRODUCT 2GROUP 410020%3
6CATEGORY 1PRODUCT 3GROUP 513,40011%1
7CATEGORY 1PRODUCT 3GROUP 655015%2
8CATEGORY 1PRODUCT 3GROUP 740018%3
9CATEGORY 1PRODUCT 3GROUP 822519%4
10CATEGORY 1PRODUCT 3GROUP 910020%5
11CATEGORY 1PRODUCT 4GROUP 740044%1
12CATEGORY 1PRODUCT 4GROUP 14009%2
13CATEGORY 1PRODUCT 4GROUP 101252%3
14CATEGORY 1PRODUCT 4GROUP 11759%4
15CATEGORY 1PRODUCT 4GROUP 125013%5
16CATEGORY 1PRODUCT 4GROUP 132516%6
17CATEGORY 1PRODUCT 4GROUP 142518%7
18CATEGORY 1PRODUCT 4GROUP 152520%8
19CATEGORY 1PRODUCT 5GROUP 842545%1
20CATEGORY 1PRODUCT 5GROUP 1637515%2
21CATEGORY 1PRODUCT 5GROUP 171502%3
22CATEGORY 1PRODUCT 5GROUP 181006%4
23CATEGORY 1PRODUCT 5GROUP 197512%5
24CATEGORY 1PRODUCT 5GROUP 205016%6
25CATEGORY 1PRODUCT 5GROUP 212518%7
26CATEGORY 1PRODUCT 5GROUP 222520%8
Sheet1 (2)

20230603_EXCEL HELP.xlsx
NOP
20C&P Count for Min%
21CATEGORY 1PRODUCT 11
22CATEGORY 1PRODUCT 22
23CATEGORY 1PRODUCT 31
24CATEGORY 1PRODUCT 43
25CATEGORY 1PRODUCT 53
Sheet1 (2)
Cell Formulas
RangeFormula
N21:O25N21=UNIQUE(B2:C26)
P21:P25P21=LET(fltfg,FILTER($F$2:$G$26,($B$2:$B$26=$N21)*($C$2:$C$26=$O21)*($F$2:$F$26)),XLOOKUP(MIN(INDEX(fltfg,,1)),INDEX(fltfg,,1),INDEX(fltfg,,2)))
Dynamic array formulas.
 
Upvote 0
Another option is
Fluff.xlsm
BCDEFGHIJK
1CATEGORY (C)PRODUCT (P)GROUP (G)QTYPERCENT (%)C+P COUNT
2CATEGORY 1PRODUCT 1GROUP 14020%1CATEGORY 1PRODUCT 22
3CATEGORY 1PRODUCT 2GROUP 220036%1
4CATEGORY 1PRODUCT 2GROUP 31502%2
5CATEGORY 1PRODUCT 2GROUP 410020%3
6CATEGORY 1PRODUCT 3GROUP 51340011%1
7CATEGORY 1PRODUCT 3GROUP 655015%2
8CATEGORY 1PRODUCT 3GROUP 740018%3
9CATEGORY 1PRODUCT 3GROUP 822519%4
10CATEGORY 1PRODUCT 3GROUP 910020%5
11CATEGORY 1PRODUCT 4GROUP 740044%1
12CATEGORY 1PRODUCT 4GROUP 14009%2
13CATEGORY 1PRODUCT 4GROUP 101252%3
14CATEGORY 1PRODUCT 4GROUP 11759%4
15CATEGORY 1PRODUCT 4GROUP 125013%5
16CATEGORY 1PRODUCT 4GROUP 132516%6
17CATEGORY 1PRODUCT 4GROUP 142518%7
18CATEGORY 1PRODUCT 4GROUP 152520%8
19CATEGORY 1PRODUCT 5GROUP 842545%1
20CATEGORY 1PRODUCT 5GROUP 1637515%2
21CATEGORY 1PRODUCT 5GROUP 171502%3
22CATEGORY 1PRODUCT 5GROUP 181006%4
23CATEGORY 1PRODUCT 5GROUP 197512%5
24CATEGORY 1PRODUCT 5GROUP 205016%6
25CATEGORY 1PRODUCT 5GROUP 212518%7
26CATEGORY 1PRODUCT 5GROUP 222520%8
27
Sheet5
Cell Formulas
RangeFormula
K2K2=TAKE(SORT(FILTER(F2:G100,(B2:B100=I2)*(C2:C100=J2))),1,-1)
 
Upvote 0
Solution
Thanks @Fluff for insight into the TAKE function. I hadn't investigated it before. Used with the SORT function in this case leads to a very nice method for extracting the desired value.

After re-examining my offering, I realized that I included an array expression that is not necessary, so a slightly shorter version of mine...
Excel Formula:
LET(fltfg,FILTER($F$2:$G$26,($B$2:$B$26=N21)*($C$2:$C$26=O21)),XLOOKUP(MIN(INDEX(fltfg,,1)),INDEX(fltfg,,1),INDEX(fltfg,,2)))
...but I like your offering much better.
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,159
Members
453,021
Latest member
Justyna P

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