SOLVED

Need Some HELP with Formula

%3CLINGO-SUB%20id%3D%22lingo-sub-1516707%22%20slang%3D%22en-US%22%3ENeed%20Some%20HELP%20with%20Formula%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1516707%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3C%2FP%3E%3CP%3EI%20will%20appreciate%20if%20somebody%20can%20help%20me%20to%20find%20the%20right%20formula%20or%20function.%20not%20sure%20if%20it%20is%20possible%20only%20through%20Formula%20or%20needs%20VBA.%20I%20tried%20UNIQUE%20and%20SORT%20but%20it%20did%20not%20Work.%26nbsp%3B%3C%2FP%3E%3CP%3EI%20attached%20both%20the%20Screenshot%20and%20Excel%20file.%3C%2FP%3E%3CP%3EI%20guess%20the%20best%20way%20to%20ask%20my%20question%20is%20with%20an%20example.%20Let's%20say%20I%20choose%20%22Blue%22%20%22red%22%20%22yellow%22%20%22white%22%20from%20column%20H%20(I%20already%20created%20a%20checkbox%20for%20this%20column%20and%20link%20each%20cell)%3C%2FP%3E%3CP%3EI%20would%20like%20to%20come%20up%20with%20a%20solution%20that%20each%20time%20I%20select%20different%20Colors%20from%20Column%20%22I%22%2C%20it%20searches%20all%20the%20cells%20in%20column%20%22inventory%201%22%20and%20those%20cells%20that%20contain%20the%20selected%20colors%20(In%20this%20case%20any%20cells%20that%20contain%26nbsp%3B%22blue%22%20%22red%22%20%22yellow%22%20%22white%22)%20be%20extracted%20to%20column%20%22New%201%22.%26nbsp%3B%3C%2FP%3E%3CP%3EAnd%20I%20can%20do%20the%20same%20for%20%22Inventory%202%22%2C%20%22Inventory%203%22...%22Inventory%205%22%20and%20results%20for%20each%20will%20be%20shown%20in%20Column%20%22NEW%202%22%20%22NEW3%22%20...%22NEW%205%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1516707%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EDeveloper%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EMacros%20and%20VBA%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1516741%22%20slang%3D%22en-US%22%3ERe%3A%20Need%20Some%20HELP%20with%20Formula%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1516741%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F714984%22%20target%3D%22_blank%22%3E%40msm66%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAssuming%20that%20the%20color%20will%20always%20be%20the%20first%20word%20of%20the%20item%20description%2C%20you%20can%20try%20this%20in%20L2%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E%3DIFERROR(INDEX(A%242%3AA%248%2CSMALL(IF(MMULT(--(LEFT(A%242%3AA%248%2CFIND(%22%20%22%2CA%242%3AA%248%26amp%3B%22%20%22)-1)%3DTRANSPOSE(%24H%242%3A%24H%248))%2C--(%24J%242%3A%24J%248))%2CROW(INDIRECT(%221%3A%22%26amp%3BROWS(A%242%3AA%248)))%2C%22%22)%2CROWS(L%242%3AL2)))%2C%22%22)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20don't%20have%20the%20filter%20function%20to%20test%20it%2C%20but%20this%20might%20work%20also%20(Ctrl%2BShift%2BEnter%20after%20keying%20or%20copying%20it%20to%20the%20formula%20bar)%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E%3DFILTER(A%242%3AA%248%2CMMULT(--(LEFT(A%242%3AA%248%2CFIND(%22%20%22%2CA%242%3AA%248%26amp%3B%22%20%22)-1)%3DTRANSPOSE(%24H%242%3A%24H%248))%2C--(%24J%242%3A%24J%248)))%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAlso%2C%20not%20there%20is%20a%20trailing%20space%20for%20%22Pink%20%22%20in%20Column%20H%20that%20was%20removed.%20I%20attached%20the%20file%20as%20well.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Contributor

Hi 

I will appreciate if somebody can help me to find the right formula or function. not sure if it is possible only through Formula or needs VBA. I tried UNIQUE and SORT but it did not Work. 

I attached both the Screenshot and Excel file.

I guess the best way to ask my question is with an example. Let's say I choose "Blue" "red" "yellow" "white" from column H (I already created a checkbox for this column and link each cell)

I would like to come up with a solution that each time I select different Colors from Column "I", it searches all the cells in column "inventory 1" and those cells that contain the selected colors (In this case any cells that contain "blue" "red" "yellow" "white") be extracted to column "New 1". 

And I can do the same for "Inventory 2", "Inventory 3"..."Inventory 5" and results for each will be shown in Column "NEW 2" "NEW3" ..."NEW 5"

 

18 Replies
Best Response confirmed by msm66 (Contributor)
Solution

@msm66 

 

Assuming that the color will always be the first word of the item description, you can try this in L2:

 

=IFERROR(INDEX(A$2:A$8,SMALL(IF(MMULT(--(LEFT(A$2:A$8,FIND(" ",A$2:A$8&" ")-1)=TRANSPOSE($H$2:$H$8)),--($J$2:$J$8)),ROW(INDIRECT("1:"&ROWS(A$2:A$8))),""),ROWS(L$2:L2))),"")

 

I don't have the filter function to test it, but this might work also (Ctrl+Shift+Enter after keying or copying it to the formula bar):

 

=FILTER(A$2:A$8,MMULT(--(LEFT(A$2:A$8,FIND(" ",A$2:A$8&" ")-1)=TRANSPOSE($H$2:$H$8)),--($J$2:$J$8)))

 

Also, not there is a trailing space for "Pink " in Column H that was removed. I attached the file as well.

 

 

@JMB17 , @msm66 

Yes, it works. Another variant could be

=IFERROR(FILTER(A1:INDEX(A:A,COUNTA(A:A)),
    MMULT(--ISNUMBER(
          SEARCH(TRANSPOSE(FILTER($H$2:$H$8,$J$2:$J$8)),
                 A1:INDEX(A:A,COUNTA(A:A)))),
          --FILTER($J$2:$J$8,$J$2:$J$8))
),"- no inventory -")

 

@JMB17 You're Rock man. The first Formula is the one I need. First is much more understandable and simple and sharp as a tack. The problem with second formula is that it finds the ones start with the color. Let's say somebody else who does not have any idea how the formula works updates the inventory every day and by accident put "HAT YELLOW" Instead of "yellow hat", However, the solution will be creating a new column next to products and call it Color. That way you make it more specific. For sure, The first formula shows everything that contains the color. In my case, works perfectly. Thanks, A lot for taking the time to solve the problem.
Thank you Sergio Balkan as well taking your time reading my problem. @JMB17 solution was a Bomb. yes, it works.

@msm66 

IMHO, both formulas check the start of the texts, that was the only reason why I adjusted second one.

Yes, I thought about using SEARCH in case the color was not the first word. But, then I thought you could run into a potential issue with the color being embedded as part of another word in the item description (like how "red" appears in the word "scared").

But, moving the color to it's own cell would certainly solve all of those potential issues. And, you could dispense with the LEFT(x, FIND()) part. And, from Sergei's post, it looks like the filter function can work, so it could be further simplified (I just don't have the filter function to play with it).

@Sergei Baklan 

I was thinking what if we have multiple columns with checkboxes to filter? can we use "AND/OR" in "FILTER"?

An example is been attached:

in this example, let's say how we can filter inventory 1 to search for items selected in both columns H and J? 

A formula that shows everything in Inventory 1 that includes (blue, black, red) and/or (Shirt, jacket or sweater)???

 

@msm66 

For OR condition you may + another MMULT, for AND multiply them as here (for OR)

image.png

formula is

=IFERROR(FILTER(A1:INDEX(A:A,COUNTA(A:A)),
--(MMULT(--ISNUMBER(
          SEARCH(TRANSPOSE(FILTER($H$2:$H$8,$J$2:$J$8)),
                 A1:INDEX(A:A,COUNTA(A:A)))),
          --FILTER($J$2:$J$8,$J$2:$J$8))+
MMULT(--ISNUMBER(
          SEARCH(TRANSPOSE(FILTER($L$2:$L$8,$N$2:$N$8)),
                 A1:INDEX(A:A,COUNTA(A:A)))),
          --FILTER($N$2:$N$8,$N$2:$N$8))
>0)),"- no inventory -")
@Sergei Baklan
Sorry for the late response. It works perfectly. you make it look super simple. Thanks, man.
verdade mesmo
liere para os inscrito o office pois precisamos para comentar melhorias e desenvolvedores
* liberem

@Sergie Baklan
I am facing a problem with the formula. It looks like we have to select at least one item from column L otherwise it won't show the results for column H. "no inventory will be the result.
in other words, let's say I do not want to select any "type" just want to check what color is available in inventory 1. or vise versa I just want to check the "type" or sometimes both.
For instance, in this example, if you uncheck all column "M" the result will be "No inventory" however in inventory 1, we have items that their color is either blue or red which we have already selected. So it can not be true.
Do you have any idea how we can adjust the formula? by this assumption that also it works if there will be more than two columns of checkboxes, not only two columns.
Your thoughts regarding this will be greatly appreciated.

@msm66 

Yes, that's a bug. I added couple of more error checks

=IFERROR(
   FILTER(A1:INDEX(A:A,COUNTA(A:A)),
      (
         IFERROR(
         --MMULT(--ISNUMBER(
            SEARCH(TRANSPOSE(FILTER($H$2:$H$8,$J$2:$J$8)),
                 A1:INDEX(A:A,COUNTA(A:A)))),
            --FILTER($J$2:$J$8,$J$2:$J$8)),
         SEQUENCE(ROWS(A1:INDEX(A:A,COUNTA(A:A))),1,0,0))   +
         IFERROR(
         --MMULT(--ISNUMBER(
            SEARCH(TRANSPOSE(FILTER($L$2:$L$8,$N$2:$N$8)),
                 A1:INDEX(A:A,COUNTA(A:A)))),
            --FILTER($N$2:$N$8,$N$2:$N$8)),
         SEQUENCE(ROWS(A1:INDEX(A:A,COUNTA(A:A))),1,0,0))
      >0)
   ),
"- no inventory -")

Result is in attached file

@Sergei Baklan No word! I am speechless. You are a magician I guess.
I have a minor issue, but not sure if it is possible to make it even more intelligent. I attached the file.
I changed the color "Blue" to "Light Red".
Let's say you just want to see the results for "Light Red" not "Red".
Is there any trick you think might work? I tried to put it between " " so maybe it can tell the difference and only show me the "LIGHT Red" but it did not work. 

Basically the formula search for everything that contains the marked checkbox. but how it can separate the "Red" from "light Red" and return the one has been checked since both contain "Red".

@msm66 

I see. Let try this modification

=IFERROR(
   FILTER(A1:INDEX(A:A,COUNTA(A:A)),
      (
IFERROR(
      MMULT(
         TRANSPOSE(--ISNUMBER(
               SEARCH($H$2:$H$8,
                   TRANSPOSE(A1:INDEX(A:A,COUNTA(A:A)))))),
          --$J$2:$J$8-
            TRANSPOSE(
                MMULT(
                   --TRANSPOSE($J$2:$J$8),
                   (--ISNUMBER(SEARCH($H$2:$H$8,TRANSPOSE($H$2:$H$8))) -
                    MUNIT(ROWS($H$2:$H$8)))
               )
           )
    ),SEQUENCE(ROWS(A1:INDEX(A:A,COUNTA(A:A))),1,0,0))   +
         IFERROR(
         --MMULT(--ISNUMBER(
            SEARCH(TRANSPOSE(FILTER($L$2:$L$8,$N$2:$N$8)),
                 A1:INDEX(A:A,COUNTA(A:A)))),
            --FILTER($N$2:$N$8,$N$2:$N$8)),
         SEQUENCE(ROWS(A1:INDEX(A:A,COUNTA(A:A))),1,0,0))
      >0)
   ),
"- no inventory -")

 

@Sergei Baklan 

It is Working!!!

I do not know what to say. but literally did not understand the code you wrote at first glance until I dig deep and learned some of the functions. All I can say you're absolutely a genius. 

Thank you. 

Expect me for more questions in the future lol

@msm66 

You are welcome. Perhaps it could be found more simple solution if write from scratch without patching initial formula one by one, but that's only possible improvement.